└── README.md
/README.md:
--------------------------------------------------------------------------------
1 | # CTDX README
2 |
3 | 通达信基本功能的通讯封装。
4 |
5 | ---
6 |
7 | ### 2020/10/09 更新
8 |
9 | 本仓库因违反了[github的DMCA规定](https://docs.github.com/articles/dmca-takedown-policy/), 清理敏感内容,保留仓库留念!
10 |
11 | ---
12 |
13 | ### 目前已有的功能
14 |
15 | 1. 获取A股股票、债券、基金等列表
16 | 1. 获取历史权息数据(高送转数据)
17 | 1. 获取日线及五分钟线盘后数据.
18 | 1. 获取历年财报数据
19 |
20 | ### 待加入的功能有
21 |
22 | 1. 加入行情监控功能
23 |
24 | ### 高送转文件格式解析
25 |
26 | 股票代码(code), 日期(date), 所属市场(market), 高送转类型(type), 送现金(money), 配股价(price), 送股数(count), 配股比例(rate)
27 |
28 | ```
29 | code, date, market, type, money, price, count, rate
30 | 1,6,13,14 分红, 配股价, 转送股, 配股 # 复权只计算 1.除权除息
31 | 2,3,4,5,7,8,9,10,11,12 前流通盘, 前总股本, 后流通盘, 后总股本
32 | ```
33 |
34 | * type的取值与含义:
35 | > 1=除权除息
36 | > 2=送配股上市(如: 000656 2015-04-29)
37 | > 3=非流通股上市(如: 000656 2010-02-10)
38 | > 4=未知股本变动(如: 600642 1993-07-19)
39 | > 5=股本变化(如: 000656 2017-06-30)
40 | > 6=增发新股(如: 600887 2002-08-20)
41 | > 7=股份回购(如: 600619 2000-09-08)
42 | > 8=增发新股上市(如: 600186 2001-02-14)
43 | > 9=转配股上市(如: 600811 2017-07-25)
44 | > 10=可转债上市(如: 600418 2006-07-07)
45 | > 11=扩缩股(如: 600381 2014-06-27)
46 | > 12=非流通股缩股(如: 600339 2006-04-10)
47 | > 13=送认购权证(如: 600008 2006-04-19)
48 | > 14=送认沽权证(如: 000932 2006-03-01)
49 |
50 | 根据type取值的不同,`money`、`price`、`count`、`rate` 的含义也不同:
51 | * 在除权除息(type=1)或者增发新股(type=6)时,含义分别是: `分红(money), 配股价(price), 送股数(count), 配股比例(rate)`
52 | * 其它取值时,含义分别是: `前流通盘(money), 前总股本(price), 后流通盘(count), 后总股本(rate)`
53 |
54 | ## 其它说明
55 |
56 | 1. 本程序用到的股票交易日历是: `https://mall.datayes.com/datapreview/1293?lang=zh`
57 | 2. 由于通联数据接口不再免费,增量日历数据通过工具生成: `https://github.com/datochan/SCGenerator`
58 |
59 | ## 代码示例
60 |
61 | ```
62 | // 获取通达信中基础交易商品
63 |
64 | package main
65 |
66 | import (
67 | "os"
68 | "fmt"
69 | "strings"
70 |
71 | "github.com/datochan/gcom/logger"
72 |
73 | "github.com/datochan/ctdx"
74 | "github.com/datochan/ctdx/comm"
75 | )
76 |
77 | func main() {
78 | configure := new(comm.Conf)
79 | configure.Parse("/Users/datochan/WorkSpace/GoglandProjects/src/Test/configure.toml")
80 |
81 |
82 | strLevel := strings.ToUpper(configure.App.Logger.Level)
83 | switch strLevel {
84 | case "DEBUG": logger.InitFileLog(os.Stdout, configure.App.Logger.Name, logger.LvDebug)
85 | case "INFO": logger.InitFileLog(os.Stdout, configure.App.Logger.Name, logger.LvInfo)
86 | case "WARN": logger.InitFileLog(os.Stdout, configure.App.Logger.Name, logger.LvWarn)
87 | case "ERROR": logger.InitFileLog(os.Stdout, configure.App.Logger.Name, logger.LvError)
88 | case "FATAL": logger.InitFileLog(os.Stdout, configure.App.Logger.Name, logger.LvFatal)
89 | default:
90 | logger.InitFileLog(os.Stdout, configure.App.Logger.Name, logger.LvWarn)
91 | }
92 |
93 | // 默认加载股票交易日历数据
94 | calendarPath := fmt.Sprintf("%s%s", configure.App.DataPath, configure.Tdx.Files.Calendar)
95 | _, err := comm.DefaultStockCalendar(calendarPath)
96 |
97 | if nil != err {
98 | logger.Error("%v", err)
99 | return
100 | }
101 |
102 | logger.Info("更新基础的股票数据...")
103 | tdxClient := ctdx.NewDefaultTdxClient(configure)
104 | defer tdxClient.Close()
105 |
106 | tdxClient.Conn()
107 | tdxClient.UpdateStockBase()
108 |
109 | // 更新结束后会向管道中发送一个通知
110 | <- tdxClient.Finished
111 |
112 | logger.Info("更新结束...")
113 |
114 | tdxClient.Close()
115 |
116 | }
117 | ```
118 |
--------------------------------------------------------------------------------