|
|
@@ -41,6 +41,13 @@ class Finance163
|
|
|
return $content1;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /***
|
|
|
+ * @param $stock_code
|
|
|
+ * @param $start_date
|
|
|
+ * @param $end_date
|
|
|
+ * @return mixed
|
|
|
+ */
|
|
|
static public function get_history_index_csi300($stock_code,$start_date,$end_date)
|
|
|
{
|
|
|
$code = self::stock_block($stock_code);
|
|
|
@@ -79,6 +86,13 @@ class Finance163
|
|
|
return $msg;
|
|
|
}
|
|
|
|
|
|
+ /***
|
|
|
+ * @param $stock_code
|
|
|
+ * @param $start_date
|
|
|
+ * @param $end_date
|
|
|
+ * @return mixed
|
|
|
+ *
|
|
|
+ */
|
|
|
static public function get_history_index_gem($stock_code,$start_date,$end_date)
|
|
|
{
|
|
|
$code = self::stock_block($stock_code);
|
|
|
@@ -116,6 +130,13 @@ class Finance163
|
|
|
}
|
|
|
return $msg;
|
|
|
}
|
|
|
+
|
|
|
+ /***
|
|
|
+ * @param $stock_code
|
|
|
+ * @param $start_date
|
|
|
+ * @param $end_date
|
|
|
+ * @return mixed
|
|
|
+ */
|
|
|
static public function get_history_index_kc50($stock_code,$start_date,$end_date)
|
|
|
{
|
|
|
$code = self::stock_block($stock_code);
|
|
|
@@ -153,6 +174,13 @@ class Finance163
|
|
|
}
|
|
|
return $msg;
|
|
|
}
|
|
|
+
|
|
|
+ /***
|
|
|
+ * @param $stock_code
|
|
|
+ * @param $start_date
|
|
|
+ * @param $end_date
|
|
|
+ * @return mixed
|
|
|
+ */
|
|
|
static public function get_history_index_scz($stock_code,$start_date,$end_date)
|
|
|
{
|
|
|
$code = self::stock_block($stock_code);
|
|
|
@@ -190,6 +218,13 @@ class Finance163
|
|
|
}
|
|
|
return $msg;
|
|
|
}
|
|
|
+
|
|
|
+ /***
|
|
|
+ * @param $stock_code
|
|
|
+ * @param $start_date
|
|
|
+ * @param $end_date
|
|
|
+ * @return mixed
|
|
|
+ */
|
|
|
static public function get_history_index_sh($stock_code,$start_date,$end_date)
|
|
|
{
|
|
|
$code = self::stock_block($stock_code);
|
|
|
@@ -227,6 +262,15 @@ class Finance163
|
|
|
}
|
|
|
return $msg;
|
|
|
}
|
|
|
+
|
|
|
+ /****
|
|
|
+ * @param $stock_code
|
|
|
+ * @param $start_date
|
|
|
+ * @param $end_date
|
|
|
+ * @return mixed|string
|
|
|
+ * 王刚涛
|
|
|
+ * 获取上证50的历史数据
|
|
|
+ */
|
|
|
static public function get_history_index_sh50($stock_code,$start_date,$end_date)
|
|
|
{
|
|
|
$msg="";
|
|
|
@@ -266,7 +310,48 @@ class Finance163
|
|
|
return $msg;
|
|
|
}
|
|
|
|
|
|
+ /***
|
|
|
+ * 获取股票交易的当天数据,在新浪的文件中调用该函数,
|
|
|
+ * 用于补齐字段信息
|
|
|
+ * startdate+1=enddate
|
|
|
+ */
|
|
|
+ static public function get_day_k_data($stock_code){
|
|
|
+ $date=date("Ymd",time());//设置开始时间和结束时间
|
|
|
+// $start_date=$date;
|
|
|
+// $end_date=$date;
|
|
|
+ $start_date=20201123;
|
|
|
+ $end_date=20201123;
|
|
|
|
|
|
+ $code = self::stock_block($stock_code);
|
|
|
+// $url = "http://quotes.money.163.com/service/chddata.html?code=" . $code . "&fields=TOPEN;HIGH;LOW;TCLOSE;VATURNOVER;VOTURNOVER;LCLOSE;CHG;PCHG;TURNOVER;";
|
|
|
+ $url = "http://quotes.money.163.com/service/chddata.html?code=" . $code . "&start=" . $start_date . "&end=" . $end_date . "&fields=TOPEN;HIGH;LOW;TCLOSE;VATURNOVER;VOTURNOVER;LCLOSE;CHG;PCHG;TURNOVER";
|
|
|
+
|
|
|
+ //构建所要发送的url,前收盘价,涨跌幅,涨跌价,换手率
|
|
|
+ $content1=Finance163::curl_get_data($url);
|
|
|
+ if (!empty($content1[1])) {
|
|
|
+ for ($i = count($content1) - 1; $i >0; $i--) {//排除日期,代码等标题栏
|
|
|
+ if (!empty($content1[$i])) {
|
|
|
+ $content3 = explode(",", iconv("gbk", "utf-8", $content1[$i]));
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+// 解析返回的历史数据
|
|
|
+ $data['close_price_qfq'] = floatval($content3[9]);//前收盘价
|
|
|
+ $data['increase_price'] = floatval($content3[10]);//涨跌幅
|
|
|
+ $data['increase_value'] = floatval($content3[11]);//涨跌价
|
|
|
+ $data['turnover'] = floatval($content3[12]);//换手率
|
|
|
+ //将所要存储的数据放入一个数组中
|
|
|
+ $stock_name = $content3[1];
|
|
|
+ if ($data['close_price'] == 0) {//当收盘价为0的时候,表示此时的基于9-3点,所以不存储
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+// var_dump($data);
|
|
|
+ return $data;
|
|
|
+ }
|
|
|
/***
|
|
|
* @param $code
|
|
|
* @return int
|