|
@@ -6,25 +6,12 @@ import (
|
|
|
"fmt"
|
|
|
"github.com/rdlucklib/rdluck_tools/http"
|
|
|
"github.com/shopspring/decimal"
|
|
|
+ "hongze/hongze_edb_lib/models"
|
|
|
+ "hongze/hongze_edb_lib/models/future_good"
|
|
|
"hongze/hongze_edb_lib/utils"
|
|
|
"reflect"
|
|
|
)
|
|
|
|
|
|
-type EdbDataFromThs struct {
|
|
|
- DataVol int64 `json:"dataVol"`
|
|
|
- Errmsg string `json:"errmsg"`
|
|
|
- Errorcode int64 `json:"errorcode"`
|
|
|
- Perf interface{} `json:"perf"`
|
|
|
- Tables []Tables `json:"tables"`
|
|
|
-}
|
|
|
-
|
|
|
-// Tables 表格数据
|
|
|
-type Tables struct {
|
|
|
- ID []string `json:"id"`
|
|
|
- Time []string `json:"time"`
|
|
|
- Value []float64 `json:"value"`
|
|
|
-}
|
|
|
-
|
|
|
// EdbDataFromThsInterface 数据类型转为interface
|
|
|
type EdbDataFromThsInterface struct {
|
|
|
DataVol int64 `json:"dataVol"`
|
|
@@ -38,12 +25,12 @@ type EdbDataFromThsInterface struct {
|
|
|
} `json:"tables"`
|
|
|
}
|
|
|
|
|
|
-func GetEdbDataFromThs(edbCode, startDate, endDate string) (item *EdbDataFromThs, err error) {
|
|
|
+func GetEdbDataFromThs(edbCode, startDate, endDate string) (item *models.EdbDataFromThs, err error) {
|
|
|
return getEdbDataFromThs(edbCode, startDate, endDate, 0)
|
|
|
}
|
|
|
|
|
|
// getEdbDataFromThs 获取同花顺接口数据
|
|
|
-func getEdbDataFromThs(edbCode, startDate, endDate string, num int) (item *EdbDataFromThs, err error) {
|
|
|
+func getEdbDataFromThs(edbCode, startDate, endDate string, num int) (item *models.EdbDataFromThs, err error) {
|
|
|
thsUrl := utils.Hz_Wind_Data_Url + `edbInfo/ths?EdbCode=%s&StartDate=%s&EndDate=%s`
|
|
|
thsUrl = fmt.Sprintf(thsUrl, edbCode, startDate, endDate)
|
|
|
utils.FileLog.Info("thsUrl:" + thsUrl)
|
|
@@ -77,7 +64,7 @@ func getEdbDataFromThs(edbCode, startDate, endDate string, num int) (item *EdbDa
|
|
|
}
|
|
|
|
|
|
// 因为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)
|
|
@@ -108,14 +95,14 @@ func getEdbDataFromThs(edbCode, startDate, endDate string, num int) (item *EdbDa
|
|
|
}
|
|
|
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,
|
|
@@ -159,31 +146,8 @@ type FutureGoodDataFromThsInterface struct {
|
|
|
} `json:"tables"`
|
|
|
}
|
|
|
|
|
|
-// FutureGoodDataFromThs 同花顺期货数据
|
|
|
-type FutureGoodDataFromThs struct {
|
|
|
- DataVol int64 `json:"dataVol"`
|
|
|
- Errmsg string `json:"errmsg"`
|
|
|
- Errorcode int64 `json:"errorcode"`
|
|
|
- Perf interface{} `json:"perf"`
|
|
|
- Tables FutureGoodDataTables `json:"tables"`
|
|
|
-}
|
|
|
-
|
|
|
-// FutureGoodDataTables 同花顺表格数据
|
|
|
-type FutureGoodDataTables struct {
|
|
|
- //TradeCode []string `json:"id"`
|
|
|
- Time []string `json:"time"`
|
|
|
- Open []float64 `json:"open"`
|
|
|
- High []float64 `json:"high"`
|
|
|
- Low []float64 `json:"low"`
|
|
|
- Close []float64 `json:"close"`
|
|
|
- Volume []float64 `json:"volume"`
|
|
|
- Amount []float64 `json:"amount"`
|
|
|
- Ccl []float64 `json:"ccl"`
|
|
|
- Settlement []float64 `json:"settlement"`
|
|
|
-}
|
|
|
-
|
|
|
// GetFutureGoodDataFromThs 通过url获取wind的商品数据
|
|
|
-func GetFutureGoodDataFromThs(edbCode, startDate, endDate string, num int) (item *FutureGoodDataFromThs, err error) {
|
|
|
+func GetFutureGoodDataFromThs(edbCode, startDate, endDate string, num int) (item *future_good.FutureGoodDataFromThs, err error) {
|
|
|
thsUrl := utils.Hz_Wind_Data_Url + `edbInfo/ths/future_good?EdbCode=%s&StartDate=%s&EndDate=%s`
|
|
|
thsUrl = fmt.Sprintf(thsUrl, edbCode, startDate, endDate)
|
|
|
utils.FileLog.Info("thsUrl:" + thsUrl)
|
|
@@ -220,12 +184,12 @@ func GetFutureGoodDataFromThs(edbCode, startDate, endDate string, num int) (item
|
|
|
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,
|