Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
stock_new
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sugar
stock_new
Commits
51342211
Commit
51342211
authored
Jun 19, 2024
by
wuxiaoli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
no message
parent
98775249
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
122 deletions
+0
-122
application/common.php
application/common.php
+0
-122
No files found.
application/common.php
View file @
51342211
...
...
@@ -2087,128 +2087,6 @@ if(!function_exists('get_between')) {
$substr
=
substr
(
$input
,
strlen
(
$start
)
+
strpos
(
$input
,
$start
),
(
strlen
(
$input
)
-
strpos
(
$input
,
$end
))
*
(
-
1
));
return
$substr
;
}
//腾讯数据解析
if
(
!
function_exists
(
'jsonQuotation'
))
{
function
jsonQuotation
(
$item
)
{
$item
[
0
]
=
isset
(
$item
[
0
])
?
substr
(
str_replace
(
'v_'
,
''
,
$item
[
0
]),
0
,
2
)
:
''
;
//交易所代号
$item
[
80
]
=
isset
(
$item
[
30
])
?
strtotime
(
$item
[
30
])
:
time
();
return
$item
;
}
}
/*
* 通过API接口获取全部股票列表
*/
if
(
!
function_exists
(
'apiStockList'
))
{
function
apiStockList
(){
$url
=
"http://"
.
LOCAL_STOCK_HOST
.
":"
.
LOCAL_STOCK_PORT
.
"/api/market/getStockList"
;
$result
=
curls
(
$url
);
$data
=
json_decode
(
$result
,
true
);
$json
=
isset
(
$data
[
'data'
])
?
$data
[
'data'
]
:
[];
return
$json
;
}
}
/*
* 获取新浪热门行业
*/
if
(
!
function_exists
(
'getSinahy'
))
{
function
getSinahy
(){
$output
=
curl
(
'https://vip.stock.finance.sina.com.cn/q/view/newSinaHy.php'
);
if
(
$output
){
$findme
=
'{"'
;
$pos
=
strpos
(
$output
,
$findme
)
+
2
;
$output
=
substr
(
$output
,
$pos
,
-
2
);
$t2
=
explode
(
'","'
,
mb_convert_encoding
(
$output
,
'utf-8'
,
'gbk'
));
$res
=
array
();
foreach
(
$t2
as
$k
=>
$v
)
{
$res
[
$k
]
=
explode
(
','
,
substr
(
explode
(
':'
,
$v
)[
1
],
1
));
}
return
$res
?:
false
;
}
else
{
return
false
;
}
}
}
//新浪股票热门行业分类排行
if
(
!
function_exists
(
'getSinaNodeclass'
))
{
function
getSinaNodeclass
(
$node
,
$page
=
1
,
$num
=
50
){
$url
=
'https://vip.stock.finance.sina.com.cn/quotes_service/api/json_v2.php/Market_Center.getHQNodeData?page='
.
$page
.
'&num='
.
$num
.
'&sort=symbol&asc=1&node='
.
$node
;
$json
=
curl
(
$url
);
$data
=
json_decode
(
$json
,
true
);
return
$data
?:
false
;
}
}
/*
* 远程访问
*/
if
(
!
function_exists
(
'curls'
))
{
function
curls
(
$url
,
$data
=
[])
{
$curl
=
curl_init
();
curl_setopt
(
$curl
,
CURLOPT_URL
,
$url
);
curl_setopt
(
$curl
,
CURLOPT_RETURNTRANSFER
,
1
);
curl_setopt
(
$curl
,
CURLOPT_HTTPHEADER
,
array
(
'Access-Token:'
.
LOCAL_TRADING_TOKEN
,
'Client-Host:'
.
RedisUtil
::
getClientHost
(),
));
curl_setopt
(
$curl
,
CURLOPT_POST
,
1
);
curl_setopt
(
$curl
,
CURLOPT_POSTFIELDS
,
$data
);
curl_setopt
(
$curl
,
CURLOPT_TIMEOUT
,
10
);
$res
=
curl_exec
(
$curl
);
curl_close
(
$curl
);
return
$res
;
}
}
/*
* 通过API接口获取行情
*/
if
(
!
function_exists
(
'getApiStock'
))
{
/**
* @param $code
* @param string $model
* @return array|mixed
*/
function
getApiStock
(
$code
,
$model
=
'stock'
){
//$recData['data'] = ThirdMarket($code,$model);
/**********************腾讯证券网********************/
$recData
[
'data'
]
=
TencentMarkets
(
$code
);
//$recData['data'] = east_market($code,$model);
switch
(
$model
)
{
case
'stock'
://
单个股票
$stockData
=
isset
(
$recData
[
'data'
])
?
$recData
[
'data'
][
0
]
:
[];
break
;
case
'stocks'
://
多个股票
$stockData
=
isset
(
$recData
[
'data'
])
?
$recData
[
'data'
]
:
[];
break
;
default
:
$stockData
=
isset
(
$recData
[
'data'
])
?
$recData
[
'data'
][
0
]
:
[];
break
;
}
return
$stockData
;
}
}
//腾讯数据获取
if
(
!
function_exists
(
'TencentMarkets'
))
{
function
TencentMarkets
(
$code
){
$url
=
'https://qt.gtimg.cn/q='
.
$code
;
//print_r($url);exit;
$output
=
curl
(
$url
);
$str
=
mb_convert_encoding
(
$output
,
'utf-8'
,
'gbk'
);
$str
=
str_replace
(
array
(
"
\r\n
"
,
"
\r
"
,
"
\n
"
),
""
,
$str
);
$t2
=
explode
(
'";'
,
$str
);
$json
=
[];
foreach
(
$t2
as
$key
=>
$val
)
{
$array
=
explode
(
"~"
,
$val
);
if
(
isset
(
$array
[
2
])
&&
isset
(
$array
[
3
])
&&
isset
(
$array
[
4
])){
$json
[]
=
jsonQuotation
(
explode
(
"~"
,
$val
));
}
else
{
continue
;
}
}
return
$json
;
}
}
}
/*
* 计算佣金
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment