|
@@ -5,6 +5,8 @@ import (
|
|
|
"errors"
|
|
|
"fmt"
|
|
|
"github.com/shopspring/decimal"
|
|
|
+ "hongze/hongze_edb_lib/models"
|
|
|
+ "hongze/hongze_edb_lib/models/future_good"
|
|
|
"hongze/hongze_edb_lib/services/alarm_msg"
|
|
|
"hongze/hongze_edb_lib/utils"
|
|
|
"io"
|
|
@@ -18,7 +20,7 @@ import (
|
|
|
var refreshToken = `eyJzaWduX3RpbWUiOiIyMDIzLTAzLTI0IDEzOjQ3OjExIn0=.eyJ1aWQiOiI1NzY2NDgxMDkifQ==.339B8D21168AC21A0F80840544E38378AB2D04A02D325F0CD1C44251915233F6`
|
|
|
var tokenRedisKey = `THS_SERVER_ACCESS_TOKEN`
|
|
|
|
|
|
-func GetEdbDataFromThsHttp(edbCode, startDate, endDate string) (item EdbDataFromThs, err error) {
|
|
|
+func GetEdbDataFromThsHttp(edbCode, startDate, endDate string) (item models.EdbDataFromThs, err error) {
|
|
|
thsUrl := `https://quantapi.51ifind.com/api/v1/edb_service`
|
|
|
//indicators 是 半角逗号分隔的所有指标,宏观指标过多,推荐使用Windows超级命令生成。 "indicators":"M001620326,M002822183"
|
|
|
//functionpara 否 key-value格式,省略时不进行更新时间筛选。两个时间控件更新起始时间(startrtime)和更新结束时间(endrtime),不勾选时省略见下方代码块
|
|
@@ -47,7 +49,7 @@ func GetEdbDataFromThsHttp(edbCode, startDate, endDate string) (item EdbDataFrom
|
|
|
return
|
|
|
}
|
|
|
// 因为table里面的value有的时候返回的是string,有的是float64,所以需要用interface来反射取值
|
|
|
- tablesList := make([]Tables, 0)
|
|
|
+ tablesList := make([]models.Tables, 0)
|
|
|
for _, table := range tmpItems.Tables {
|
|
|
tableIdList := make([]string, 0)
|
|
|
tableTimeList := make([]string, 0)
|
|
@@ -78,14 +80,14 @@ func GetEdbDataFromThsHttp(edbCode, startDate, endDate string) (item EdbDataFrom
|
|
|
}
|
|
|
tableValueList = append(tableValueList, tableValue)
|
|
|
}
|
|
|
- tmpTable := Tables{
|
|
|
+ tmpTable := models.Tables{
|
|
|
ID: tableIdList,
|
|
|
Time: tableTimeList,
|
|
|
Value: tableValueList,
|
|
|
}
|
|
|
tablesList = append(tablesList, tmpTable)
|
|
|
}
|
|
|
- item = EdbDataFromThs{
|
|
|
+ item = models.EdbDataFromThs{
|
|
|
DataVol: tmpItems.DataVol,
|
|
|
Errmsg: tmpItems.Errmsg,
|
|
|
Errorcode: tmpItems.Errorcode,
|
|
@@ -96,7 +98,7 @@ func GetEdbDataFromThsHttp(edbCode, startDate, endDate string) (item EdbDataFrom
|
|
|
}
|
|
|
|
|
|
// GetFutureGoodDataFromThsHttp 通过url获取同花顺的商品数据
|
|
|
-func GetFutureGoodDataFromThsHttp(edbCode, startDate, endDate string) (item FutureGoodDataFromThs, err error) {
|
|
|
+func GetFutureGoodDataFromThsHttp(edbCode, startDate, endDate string) (item future_good.FutureGoodDataFromThs, err error) {
|
|
|
thsUrl := `https://quantapi.51ifind.com/api/v1/cmd_history_quotation`
|
|
|
|
|
|
//codes 是 半角逗号分隔的所有代码 "codes":"300033.SZ,600030.SH"
|
|
@@ -133,12 +135,12 @@ func GetFutureGoodDataFromThsHttp(edbCode, startDate, endDate string) (item Futu
|
|
|
return
|
|
|
}
|
|
|
table := tmpItems.Tables[0]
|
|
|
- item = FutureGoodDataFromThs{
|
|
|
+ item = future_good.FutureGoodDataFromThs{
|
|
|
DataVol: tmpItems.DataVol,
|
|
|
Errmsg: tmpItems.Errmsg,
|
|
|
Errorcode: tmpItems.Errorcode,
|
|
|
Perf: tmpItems.Perf,
|
|
|
- Tables: FutureGoodDataTables{
|
|
|
+ Tables: future_good.FutureGoodDataTables{
|
|
|
Time: table.Time,
|
|
|
Open: table.Table.Open,
|
|
|
High: table.Table.High,
|