Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
token
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wallet
token
Commits
3759c4c5
Commit
3759c4c5
authored
Nov 06, 2019
by
shajiaiming
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into feature/explore
parents
9046729c
2ddb27c9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
381 additions
and
159 deletions
+381
-159
CoinController.php
api/controllers/CoinController.php
+1
-0
ServiceController.php
api/controllers/ServiceController.php
+2
-2
TickerController.php
api/controllers/TickerController.php
+9
-2
Tools.php
common/components/Tools.php
+166
-0
Coin.php
common/models/psources/Coin.php
+21
-12
BinanceBuilder.php
common/service/exchange/factory/BinanceBuilder.php
+55
-71
FactoryService.php
common/service/exchange/factory/FactoryService.php
+3
-0
HuobiBuilder.php
common/service/exchange/factory/HuobiBuilder.php
+56
-34
ZhaobiBuilder.php
common/service/exchange/factory/ZhaobiBuilder.php
+68
-38
No files found.
api/controllers/CoinController.php
View file @
3759c4c5
...
...
@@ -244,6 +244,7 @@ class CoinController extends BaseController
$chain_quotation
[
$value
]
=
ExchangeBusiness
::
getquatation
(
$value
);
}
foreach
(
$result
[
'data'
]
as
$key
=>
&
$value
)
{
if
(
!
isset
(
$value
[
'nickname'
])
||
empty
(
$value
[
'nickname'
]))
continue
;
$nickname
=
json_decode
(
$value
[
'nickname'
],
true
);
$introduce
=
json_decode
(
$value
[
'introduce'
],
true
);
$value
[
'nickname'
]
=
$nickname
[
$this
->
lang
];
...
...
api/controllers/ServiceController.php
View file @
3759c4c5
...
...
@@ -100,7 +100,7 @@ class ServiceController extends BaseController
$type
=
Yii
::
$app
->
request
->
get
(
'type'
,
1
);
$coin_recommendItems
=
$this
->
coinRecommendList
(
$platform_id
,
$type
);
$fields
=
[
'id'
,
'sid'
,
'icon'
,
'name'
,
'nickname'
,
'chain'
,
'platform'
];
$rows
=
Coin
::
getSelectList
(
1
,
999
,
$fields
,
[[
'in'
,
'id'
,
$coin_recommendItems
]]);
$rows
=
Coin
::
getSelectList
(
1
,
999
,
$fields
,
[[
'in'
,
'id'
,
$coin_recommendItems
]]
,
$coin_recommendItems
);
foreach
(
$rows
[
'data'
]
as
$key
=>
&
$value
)
{
$nickname
=
json_decode
(
$value
[
'nickname'
],
true
);
$value
[
'nickname'
]
=
$nickname
[
$this
->
lang
];
...
...
@@ -114,7 +114,7 @@ class ServiceController extends BaseController
*/
private
function
coinRecommendList
(
$platform_id
,
$type
=
1
)
{
$recommend_list
=
CoinRecommend
::
find
()
->
select
(
'cid'
)
->
where
([
'platform_id'
=>
$platform_id
,
'type'
=>
$type
])
->
all
();
$recommend_list
=
CoinRecommend
::
find
()
->
select
(
'cid'
)
->
where
([
'platform_id'
=>
$platform_id
,
'type'
=>
$type
])
->
orderBy
(
'sort'
)
->
all
();
if
(
$recommend_list
)
{
$coin_ids
=
array_column
(
$recommend_list
,
'cid'
);
return
$coin_ids
;
...
...
api/controllers/TickerController.php
View file @
3759c4c5
...
...
@@ -23,7 +23,7 @@ class TickerController extends BaseController
$platform_id
=
Yii
::
$app
->
request
->
get
(
'device_code'
,
0
);
$exchange
=
Yii
::
$app
->
request
->
get
(
'exchange'
,
'zhaobi'
);
$data_value
=
Yii
::
$app
->
request
->
get
(
'data-value'
,
''
);
$sort
=
Yii
::
$app
->
request
->
get
(
'sort
'
,
''
);
$sort
_value
=
Yii
::
$app
->
request
->
get
(
'sort-value
'
,
''
);
$exchange_arr
=
[
'huobi'
,
'binance'
,
'okex'
,
'zhaobi'
];
...
...
@@ -33,8 +33,15 @@ class TickerController extends BaseController
$data
=
[];
goto
doEnd
;
}
$condition
=
[];
if
(
false
!=
$data_value
&&
false
!=
$sort_value
)
{
$condition
=
[
'data_value'
=>
$data_value
,
'sort_value'
=>
$sort_value
];
}
$builder
=
ExchangeBuilderFactory
::
create
(
$exchange
);
$result
=
$builder
->
getTickerFromCache
(
$page
);
$result
=
$builder
->
getTickerFromCache
(
$page
,
$condition
);
$code
=
$result
[
'code'
];
$data
=
$result
[
'data'
];
...
...
common/components/Tools.php
0 → 100644
View file @
3759c4c5
<?php
namespace
common\components
;
use
Yii
;
use
yii\helpers\Url
;
use
yii\helpers\ArrayHelper
;
class
Tools
{
/**
* 获取随机验证码
* @return string
*/
public
static
function
getRandomNumber
(
$count
=
6
,
$type
=
'mixed'
)
{
$chars
=
'1234567890abcdefghijklmnopqrstuvwxyz'
;
switch
(
$type
)
{
case
'number'
:
$startIndex
=
0
;
$endIndex
=
9
;
break
;
case
'letter'
:
$startIndex
=
10
;
$endIndex
=
35
;
break
;
default
:
$startIndex
=
0
;
$endIndex
=
35
;
break
;
}
$randomNumber
=
''
;
for
(
$i
=
0
;
$i
<
$count
;
$i
++
)
{
$randomNumber
.=
substr
(
$chars
,
rand
(
$startIndex
,
$endIndex
),
1
);
}
return
$randomNumber
;
}
/**
* 获取文件全路径
* @param type $filename
* @param type $type
* @return string
*/
public
static
function
getFileUrl
(
$filename
,
$type
)
{
return
$filename
;
switch
(
$type
)
{
case
'case'
:
return
$filename
?
Url
::
to
(
'@resDomain/'
.
$type
.
'/'
.
$filename
)
:
''
;
case
'video'
:
return
$filename
?
Url
::
to
(
'@resDomain/'
.
$type
.
'/'
.
$filename
)
:
''
;
case
'banner'
:
return
$filename
?
Url
::
to
(
'@resDomain/'
.
$type
.
'/'
.
$filename
)
:
''
;
case
'weixin'
:
return
$filename
?
Url
::
to
(
'@resDomain/'
.
$type
.
'/'
.
$filename
)
:
''
;
case
'public'
:
return
$filename
?
Url
::
to
(
'@resDomain/'
.
$type
.
'/'
.
$filename
)
:
''
;
default
:
return
''
;
}
}
public
static
function
getGradeFile
(
$grade
)
{
return
Url
::
to
(
'@resDomain/grade/a'
.
$grade
.
'.png'
);
}
/**
* 判断当前日期是否是可用日期
* @param type $startData
* @param type $endData
*/
public
static
function
isAvailableDate
(
$start
,
$end
)
{
$current
=
date
(
'Y-m-d'
);
$start
=
$start
?
date
(
'Y-m-d'
,
strtotime
(
$start
))
:
$current
;
$end
=
$end
?
date
(
'Y-m-d'
,
strtotime
(
$end
))
:
$current
;
if
(
$start
<=
$current
&&
$end
>=
$current
)
{
return
true
;
}
else
{
return
false
;
}
}
/**
* 添加get查询数据
* @param type $values
*/
public
static
function
addQueryParams
(
$values
)
{
Yii
::
$app
->
request
->
setQueryParams
(
ArrayHelper
::
merge
(
Yii
::
$app
->
request
->
get
(),
$values
));
}
/**
* 获取post数据, 可附加额外数据
* @param array $values 附加数据,必须是数组形式
* @param string $key 指定数据附加到特定键
*/
public
static
function
getPost
(
array
$values
,
$key
=
null
)
{
if
(
Yii
::
$app
->
request
->
isPost
)
{
$data
=
Yii
::
$app
->
request
->
post
();
if
(
$key
!==
null
)
{
$data
[
$key
]
=
ArrayHelper
::
merge
(
$data
[
$key
],
$values
);
}
else
{
$data
=
ArrayHelper
::
merge
(
$data
,
$values
);
}
return
$data
;
}
else
{
return
;
}
}
/*
* 截取字符串
*/
public
static
function
truncate_utf8_string
(
$string
,
$length
,
$etc
=
'...'
)
{
$result
=
''
;
$string
=
html_entity_decode
(
trim
(
strip_tags
(
$string
)),
ENT_QUOTES
,
'UTF-8'
);
$strlen
=
strlen
(
$string
);
for
(
$i
=
0
;
((
$i
<
$strlen
)
&&
(
$length
>
0
));
$i
++
)
{
if
(
$number
=
strpos
(
str_pad
(
decbin
(
ord
(
substr
(
$string
,
$i
,
1
))),
8
,
'0'
,
STR_PAD_LEFT
),
'0'
))
{
if
(
$length
<
1.0
)
{
break
;
}
$result
.=
substr
(
$string
,
$i
,
$number
);
$length
-=
1.0
;
$i
+=
$number
-
1
;
}
else
{
$result
.=
substr
(
$string
,
$i
,
1
);
$length
-=
0.5
;
}
}
$result
=
htmlspecialchars
(
$result
,
ENT_QUOTES
,
'UTF-8'
);
if
(
$i
<
$strlen
)
{
$result
.=
$etc
;
}
return
$result
;
}
public
static
function
arraySort
(
$array
,
$keys
,
$sort
=
SORT_DESC
)
{
$keysValue
=
[];
foreach
(
$array
as
$k
=>
$v
)
{
$keysValue
[
$k
]
=
$v
[
$keys
];
}
array_multisort
(
$keysValue
,
$sort
,
$array
);
return
$array
;
}
}
\ No newline at end of file
common/models/psources/Coin.php
View file @
3759c4c5
...
...
@@ -36,8 +36,8 @@ class Coin extends BaseActiveRecord
/**
* 获取币种信息列表
*
* @param int
$page
* @param int
$limit
* @param int $page
* @param int $limit
* @param array $condition
* @return array|\yii\db\ActiveRecord[]
*/
...
...
@@ -48,7 +48,7 @@ class Coin extends BaseActiveRecord
$query
=
$query
->
andWhere
(
$item
);
}
$count
=
$query
->
count
();
$data
=
$query
->
offset
((
$page
-
1
)
*
10
)
->
limit
(
$limit
)
->
asArray
()
->
all
();
$data
=
$query
->
offset
((
$page
-
1
)
*
10
)
->
limit
(
$limit
)
->
asArray
()
->
all
();
foreach
(
$data
as
$key
=>
$item
)
{
$data
[
$key
][
'price'
]
=
sprintf
(
"%0.6f"
,
$item
[
'price'
]);
}
...
...
@@ -58,19 +58,28 @@ class Coin extends BaseActiveRecord
/**
* 获取币种信息列表
*
* @param int
$page
* @param int
$limit
* @param int $page
* @param int $limit
* @param array $condition
* @return array|\yii\db\ActiveRecord[]
*/
public
static
function
getSelectList
(
$page
=
1
,
$limit
=
10
,
$columns
=
[],
$condition
=
[])
public
static
function
getSelectList
(
$page
=
1
,
$limit
=
10
,
$columns
=
[],
$condition
=
[]
,
$orderBy
=
[]
)
{
$ids_str
=
implode
(
','
,
$orderBy
);
$order
=
"FIELD(`id`,
$ids_str
)"
;
$query
=
self
::
find
();
foreach
(
$condition
as
$item
)
{
$query
=
$query
->
andWhere
(
$item
);
}
$count
=
$query
->
count
();
$data
=
$query
->
select
(
$columns
)
->
offset
((
$page
-
1
)
*
$limit
)
->
limit
(
$limit
)
->
asArray
()
->
all
();
if
(
false
!=
$orderBy
)
{
$ids_str
=
implode
(
','
,
$orderBy
);
$order
=
"FIELD(`id`,
$ids_str
)"
;
$data
=
$query
->
select
(
$columns
)
->
offset
((
$page
-
1
)
*
$limit
)
->
limit
(
$limit
)
->
asArray
()
->
orderBy
([
$order
=>
true
])
->
all
();
}
else
{
$data
=
$query
->
select
(
$columns
)
->
offset
((
$page
-
1
)
*
$limit
)
->
limit
(
$limit
)
->
asArray
()
->
all
();
}
return
[
'count'
=>
$count
,
'data'
=>
$data
];
}
...
...
@@ -173,8 +182,8 @@ class Coin extends BaseActiveRecord
/**
* 根据id列表获取币种信息
*
* @param array
$ids
[description]
* @param array
$select
[description]
* @param array
$ids
[description]
* @param array
$select
[description]
* @param string $sort_by [description]
* @return array [description]
*/
...
...
@@ -200,8 +209,8 @@ class Coin extends BaseActiveRecord
/**
* 获取推介币种信息列表
*
* @param int
$page
* @param int
$limit
* @param int $page
* @param int $limit
* @param array $condition
* @return array|\yii\db\ActiveRecord[]
*/
...
...
@@ -213,7 +222,7 @@ class Coin extends BaseActiveRecord
}
$query
=
$query
->
rightJoin
(
'coin_recommend'
,
'coin.id=coin_recommend.cid'
);
$count
=
$query
->
count
();
$data
=
$query
->
offset
((
$page
-
1
)
*
10
)
->
limit
(
$limit
)
->
asArray
()
->
all
();
$data
=
$query
->
offset
((
$page
-
1
)
*
10
)
->
limit
(
$limit
)
->
asArray
()
->
all
();
foreach
(
$data
as
$key
=>
$item
)
{
$data
[
$key
][
'price'
]
=
sprintf
(
"%0.6f"
,
$item
[
'price'
]);
}
...
...
common/service/exchange/factory/BinanceBuilder.php
View file @
3759c4c5
...
...
@@ -8,6 +8,7 @@
namespace
common\service\exchange\factory
;
use
common\components\Tools
;
use
linslin\yii2\curl\Curl
;
class
BinanceBuilder
extends
FactoryService
...
...
@@ -15,48 +16,13 @@ class BinanceBuilder extends FactoryService
protected
$base_url
=
'https://api.binance.com'
;
protected
$supported_symbol
=
'supported_symbol_binance'
;
protected
$supported_symbol_list
=
'supported_symbol_binance_list'
;
protected
$supported_symbol_close_sort_list
=
'supported_symbol_close_sort_binance_list'
;
protected
$supported_symbol_change_sort_list
=
'supported_symbol_change_sort_binance_list'
;
protected
$supported_symbol_close_asc
=
'supported_symbol_close_asc_binance'
;
protected
$supported_symbol_close_desc
=
'supported_symbol_close_desc_binance'
;
protected
$supported_symbol_change_asc
=
'supported_symbol_change_asc_binance'
;
protected
$supported_symbol_change_desc
=
'supported_symbol_change_desc_binance'
;
protected
$quotation_prefix
=
'quotation_binance_'
;
public
function
getTicker
()
{
$curl
=
new
Curl
();
$api
=
$this
->
base_url
.
'/api/v1/ticker/24hr'
;
$res
=
$curl
->
get
(
$api
,
false
);
$ticker
=
[];
if
(
is_array
(
$res
))
{
$this
->
code
=
0
;
foreach
(
$res
as
$val
)
{
foreach
(
$this
->
basic_coin
as
$k
=>
$coin
)
{
$explode_arr
=
explode
(
$coin
,
$val
[
'symbol'
]);
if
(
2
==
count
(
$explode_arr
)
&&
empty
(
$explode_arr
[
1
]))
{
$temp
=
[];
$temp
[
'symbol'
]
=
$explode_arr
[
0
]
.
'/'
.
$coin
;
$temp
[
'currency'
]
=
strtoupper
(
$explode_arr
[
0
]);
$temp
[
'base_currency'
]
=
strtoupper
(
$coin
);
$temp
[
'close'
]
=
number_format
(
$val
[
'lastPrice'
],
6
,
'.'
,
''
);
$temp
[
'close_usd'
]
=
(
float
)
sprintf
(
"%0.6f"
,
$val
[
'lastPrice'
]
*
$this
->
basic_price
[
$coin
][
'usd'
]);
$temp
[
'close_rmb'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$val
[
'lastPrice'
]
*
$this
->
basic_price
[
$coin
][
'rmb'
]);
$temp
[
'change'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$val
[
'priceChangePercent'
]);
$temp
[
'high_usd'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$val
[
'highPrice'
]
*
$this
->
basic_price
[
$coin
][
'usd'
]);
$temp
[
'low_usd'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$val
[
'lowPrice'
]
*
$this
->
basic_price
[
$coin
][
'usd'
]);
$temp
[
'high_rmb'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$val
[
'highPrice'
]
*
$this
->
basic_price
[
$coin
][
'rmb'
]);
$temp
[
'low_rmb'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$val
[
'lowPrice'
]
*
$this
->
basic_price
[
$coin
][
'rmb'
]);
$temp
[
'vol'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$val
[
'volume'
]);
$temp
[
'optional'
]
=
false
;
$temp
[
'platform_zh'
]
=
'币安'
;
$temp
[
'platform_us'
]
=
'binance'
;
array_push
(
$ticker
,
$temp
);
break
;
}
}
}
}
return
[
'code'
=>
$this
->
code
,
'ticker'
=>
$ticker
];
}
public
function
getTickerFromCache
(
$page
=
1
)
public
function
getTickerFromCache
(
$page
=
1
,
$condition
=
[])
{
$size
=
0
;
for
(
$i
=
0
;
$i
<
$page
;
$i
++
)
{
...
...
@@ -76,20 +42,42 @@ class BinanceBuilder extends FactoryService
}
}
}
$keys
=
$this
->
redis
->
lrange
(
$this
->
supported_symbol_list
,
$this
->
start
,
$this
->
end
);
if
(
false
!=
$condition
)
{
if
(
'price'
==
$condition
[
'data_value'
])
{
if
(
'price-asc'
==
$condition
[
'sort_value'
])
{
$keys
=
$this
->
redis_ticker
->
lrange
(
$this
->
supported_symbol_close_asc
,
$this
->
start
,
$this
->
end
);
}
if
(
'price-desc'
==
$condition
[
'sort_value'
])
{
$keys
=
$this
->
redis_ticker
->
lrange
(
$this
->
supported_symbol_close_desc
,
$this
->
start
,
$this
->
end
);
}
}
if
(
'change'
==
$condition
[
'data_value'
])
{
if
(
'change-asc'
==
$condition
[
'sort_value'
])
{
$keys
=
$this
->
redis_ticker
->
lrange
(
$this
->
supported_symbol_change_asc
,
$this
->
start
,
$this
->
end
);
}
if
(
'change-desc'
==
$condition
[
'sort_value'
])
{
$keys
=
$this
->
redis_ticker
->
lrange
(
$this
->
supported_symbol_change_desc
,
$this
->
start
,
$this
->
end
);
}
}
}
else
{
$keys
=
$this
->
redis
->
lrange
(
$this
->
supported_symbol_list
,
$this
->
start
,
$this
->
end
);
}
$ticker
=
[];
foreach
(
$keys
as
$val
)
{
foreach
(
$this
->
basic_coin
as
$k
=>
$coin
)
{
$explode_arr
=
explode
(
$coin
,
$val
);
if
(
2
==
count
(
$explode_arr
)
&&
empty
(
$explode_arr
[
1
]))
{
list
(
$low
,
$high
,
$close
,
$open
,
$vol
)
=
$this
->
redis
->
hmget
(
$this
->
quotation_prefix
.
strtolower
(
$val
),
'low'
,
'high'
,
'last'
,
'open'
,
'vol'
);
if
(
false
!=
$condition
)
{
list
(
$low
,
$high
,
$close
,
$open
,
$vol
)
=
$this
->
redis_ticker
->
hmget
(
$this
->
quotation_prefix
.
strtoupper
(
$val
),
'low'
,
'high'
,
'last'
,
'open'
,
'vol'
);
}
else
{
list
(
$low
,
$high
,
$close
,
$open
,
$vol
)
=
$this
->
redis
->
hmget
(
$this
->
quotation_prefix
.
strtolower
(
$val
),
'low'
,
'high'
,
'last'
,
'open'
,
'vol'
);
}
$temp
=
[];
$temp
[
'symbol'
]
=
strtoupper
(
$explode_arr
[
0
])
.
'/'
.
$coin
;
#if ('BCC/USDT' != $temp['symbol']) continue;
$temp
[
'currency'
]
=
strtoupper
(
$explode_arr
[
0
]);
$temp
[
'base_currency'
]
=
strtoupper
(
$coin
);
$temp
[
'close'
]
=
$this
->
sctonum
(
$close
,
8
);
$temp
[
'close_usd'
]
=
(
float
)
sprintf
(
"%0.6f"
,
$close
*
$this
->
basic_price
[
$coin
][
'usd'
]
);
$temp
[
'close'
]
=
rtrim
(
sprintf
(
'%.8f'
,
floatval
(
$close
)),
'0'
);
$temp
[
'close_usd'
]
=
rtrim
(
sprintf
(
'%.6f'
,
floatval
(
$close
*
$this
->
basic_price
[
$coin
][
'usd'
])),
'0'
);
$temp
[
'close_rmb'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$close
*
$this
->
basic_price
[
$coin
][
'rmb'
]);
$temp
[
'change'
]
=
(
0
==
$open
)
?
0
:
(
float
)
sprintf
(
"%0.2f"
,
(
$close
-
$open
)
/
$open
*
100
);
$temp
[
'high_usd'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$high
*
$this
->
basic_price
[
$coin
][
'usd'
]);
...
...
@@ -121,40 +109,35 @@ class BinanceBuilder extends FactoryService
$ticker
=
[];
for
(
$i
=
0
;
$i
<
$len
;
$i
++
)
{
$symbol
=
$this
->
redis
->
lindex
(
$this
->
supported_symbol_list
,
$i
);
list
(
$close
,
$open
)
=
$this
->
redis
->
hmget
(
$this
->
quotation_prefix
.
strtolower
(
$symbol
),
'last'
,
'open'
);
list
(
$close
,
$open
,
$low
,
$high
,
$vol
)
=
$this
->
redis
->
hmget
(
$this
->
quotation_prefix
.
strtolower
(
$symbol
),
'last'
,
'open'
,
'low'
,
'high'
,
'vol'
);
if
(
'0.00000000'
==
$close
)
continue
;
$temp
=
[];
$temp
[
'symbol'
]
=
strtoupper
(
$symbol
);
$temp
[
'close'
]
=
number_format
(
$close
,
6
,
'.'
,
''
);
$temp
[
'close'
]
=
$close
;
$temp
[
'low'
]
=
$low
;
$temp
[
'high'
]
=
$high
;
$temp
[
'open'
]
=
$open
;
$temp
[
'vol'
]
=
$vol
;
$temp
[
'change'
]
=
(
0
==
$open
)
?
0
:
(
float
)
sprintf
(
"%0.2f"
,
(
$close
-
$open
)
/
$open
*
100
);
array_push
(
$ticker
,
$temp
);
$key
=
$this
->
quotation_prefix
.
strtoupper
(
$symbol
);
$this
->
redis_ticker
->
hmset
(
$key
,
'low'
,
$low
,
'high'
,
$high
,
'last'
,
$close
,
'open'
,
$open
,
'vol'
,
$vol
);
}
$ticker_sort_close
=
$this
->
arraySort
(
$ticker
,
'close'
);
foreach
(
$ticker_sort_close
as
$val
)
{
$this
->
redis
->
lpush
(
$this
->
supported_symbol_close_sort_list
,
$val
[
'symbol'
]);
}
$ticker_change_close
=
$this
->
arraySort
(
$ticker
,
'change'
);
foreach
(
$ticker_change_close
as
$val
)
{
$this
->
redis
->
lpush
(
$this
->
supported_symbol_change_sort_list
,
$val
[
'symbol'
]);
}
}
protected
function
arraySort
(
$array
,
$keys
,
$sort
=
SORT_DESC
)
{
$keysValue
=
[];
foreach
(
$array
as
$k
=>
$v
)
{
$keysValue
[
$k
]
=
$v
[
$keys
];
$ticker_sort_close
=
Tools
::
arraySort
(
$ticker
,
'close'
);
$this
->
redis_ticker
->
del
(
$this
->
supported_symbol_close_asc
);
$this
->
redis_ticker
->
del
(
$this
->
supported_symbol_close_desc
);
foreach
(
$ticker_sort_close
as
$val
)
{
$this
->
redis_ticker
->
lpush
(
$this
->
supported_symbol_close_asc
,
strtoupper
(
$val
[
'symbol'
]));
$this
->
redis_ticker
->
rpush
(
$this
->
supported_symbol_close_desc
,
strtoupper
(
$val
[
'symbol'
]));
}
array_multisort
(
$keysValue
,
$sort
,
$array
);
return
$array
;
}
protected
function
sctonum
(
$num
,
$double
=
5
)
{
if
(
false
!==
strpos
(
$num
,
"e"
))
{
$a
=
explode
(
"e"
,
strtolower
(
$num
));
return
bcmul
(
$a
[
0
],
bcpow
(
10
,
$a
[
1
],
$double
),
$double
);
}
else
{
return
number_format
(
$num
,
6
,
'.'
,
''
);
$ticker_change_close
=
Tools
::
arraySort
(
$ticker
,
'change'
);
$this
->
redis_ticker
->
del
(
$this
->
supported_symbol_change_asc
);
$this
->
redis_ticker
->
del
(
$this
->
supported_symbol_change_desc
);
foreach
(
$ticker_change_close
as
$val
)
{
$this
->
redis_ticker
->
lpush
(
$this
->
supported_symbol_change_asc
,
strtoupper
(
$val
[
'symbol'
]));
$this
->
redis_ticker
->
rpush
(
$this
->
supported_symbol_change_desc
,
strtoupper
(
$val
[
'symbol'
]));
}
}
}
\ No newline at end of file
common/service/exchange/factory/FactoryService.php
View file @
3759c4c5
...
...
@@ -17,6 +17,7 @@ abstract class FactoryService
protected
$basic_price
=
[];
protected
$redis
;
protected
$redis_ticker
;
protected
$start
;
protected
$end
;
...
...
@@ -44,5 +45,6 @@ abstract class FactoryService
}
$this
->
redis
=
\Yii
::
$app
->
redis
;
$this
->
redis_ticker
=
\Yii
::
$app
->
redis_ticker
;
}
}
\ No newline at end of file
common/service/exchange/factory/HuobiBuilder.php
View file @
3759c4c5
...
...
@@ -8,6 +8,7 @@
namespace
common\service\exchange\factory
;
use
common\components\Tools
;
use
linslin\yii2\curl\Curl
;
class
HuobiBuilder
extends
FactoryService
...
...
@@ -15,8 +16,10 @@ class HuobiBuilder extends FactoryService
protected
$base_url
=
'https://api.huobi.pro'
;
protected
$supported_symbol
=
'supported_symbol_huobi'
;
protected
$supported_symbol_list
=
'supported_symbol_huobi_list'
;
protected
$supported_symbol_close_sort_list
=
'supported_symbol_close_sort_huobi_list'
;
protected
$supported_symbol_change_sort_list
=
'supported_symbol_change_sort_huobi_list'
;
protected
$supported_symbol_close_asc
=
'supported_symbol_close_asc_huobi'
;
protected
$supported_symbol_close_desc
=
'supported_symbol_close_desc_huobi'
;
protected
$supported_symbol_change_asc
=
'supported_symbol_change_asc_huobi'
;
protected
$supported_symbol_change_desc
=
'supported_symbol_change_desc_huobi'
;
protected
$quotation_prefix
=
'quotation_huobi_'
;
public
function
hotTickerUpdate
()
...
...
@@ -39,7 +42,7 @@ class HuobiBuilder extends FactoryService
}
}
public
function
getTickerFromCache
(
$page
=
1
)
public
function
getTickerFromCache
(
$page
=
1
,
$condition
=
[]
)
{
$size
=
0
;
for
(
$i
=
0
;
$i
<
$page
;
$i
++
)
{
...
...
@@ -59,19 +62,43 @@ class HuobiBuilder extends FactoryService
}
}
}
$keys
=
$this
->
redis
->
lrange
(
$this
->
supported_symbol_list
,
$this
->
start
,
$this
->
end
);
if
(
false
!=
$condition
)
{
if
(
'price'
==
$condition
[
'data_value'
])
{
if
(
'price-asc'
==
$condition
[
'sort_value'
])
{
$keys
=
$this
->
redis_ticker
->
lrange
(
$this
->
supported_symbol_close_asc
,
$this
->
start
,
$this
->
end
);
}
if
(
'price-desc'
==
$condition
[
'sort_value'
])
{
$keys
=
$this
->
redis_ticker
->
lrange
(
$this
->
supported_symbol_close_desc
,
$this
->
start
,
$this
->
end
);
}
}
if
(
'change'
==
$condition
[
'data_value'
])
{
if
(
'change-asc'
==
$condition
[
'sort_value'
])
{
$keys
=
$this
->
redis_ticker
->
lrange
(
$this
->
supported_symbol_change_asc
,
$this
->
start
,
$this
->
end
);
}
if
(
'change-desc'
==
$condition
[
'sort_value'
])
{
$keys
=
$this
->
redis_ticker
->
lrange
(
$this
->
supported_symbol_change_desc
,
$this
->
start
,
$this
->
end
);
}
}
}
else
{
$keys
=
$this
->
redis
->
lrange
(
$this
->
supported_symbol_list
,
$this
->
start
,
$this
->
end
);
}
$ticker
=
[];
foreach
(
$keys
as
$val
)
{
foreach
(
$this
->
basic_coin
as
$k
=>
$coin
)
{
$explode_arr
=
explode
(
strto
low
er
(
$coin
),
$val
);
$explode_arr
=
explode
(
strto
upp
er
(
$coin
),
$val
);
if
(
2
==
count
(
$explode_arr
)
&&
empty
(
$explode_arr
[
1
]))
{
list
(
$low
,
$high
,
$close
,
$open
,
$vol
)
=
$this
->
redis
->
hmget
(
$this
->
quotation_prefix
.
strtolower
(
$val
),
'low'
,
'high'
,
'last'
,
'open'
,
'vol'
);
if
(
false
!=
$condition
)
{
list
(
$low
,
$high
,
$close
,
$open
,
$vol
)
=
$this
->
redis_ticker
->
hmget
(
$this
->
quotation_prefix
.
strtoupper
(
$val
),
'low'
,
'high'
,
'last'
,
'open'
,
'vol'
);
}
else
{
list
(
$low
,
$high
,
$close
,
$open
,
$vol
)
=
$this
->
redis
->
hmget
(
$this
->
quotation_prefix
.
strtolower
(
$val
),
'low'
,
'high'
,
'last'
,
'open'
,
'vol'
);
}
$temp
=
[];
$temp
[
'symbol'
]
=
strtoupper
(
$explode_arr
[
0
])
.
'/'
.
$coin
;
$temp
[
'currency'
]
=
strtoupper
(
$explode_arr
[
0
]);
$temp
[
'base_currency'
]
=
strtoupper
(
$coin
);
$temp
[
'close'
]
=
$this
->
sctonum
(
$close
,
8
);
$temp
[
'close_usd'
]
=
(
float
)
sprintf
(
"%0.6f"
,
$close
*
$this
->
basic_price
[
$coin
][
'usd'
]
);
$temp
[
'close'
]
=
rtrim
(
sprintf
(
'%.8f'
,
floatval
(
$close
)),
'0'
);
$temp
[
'close_usd'
]
=
rtrim
(
sprintf
(
'%.6f'
,
floatval
(
$close
*
$this
->
basic_price
[
$coin
][
'usd'
])),
'0'
);
$temp
[
'close_rmb'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$close
*
$this
->
basic_price
[
$coin
][
'rmb'
]);
$temp
[
'change'
]
=
(
false
==
$open
)
?
0
:
(
float
)
sprintf
(
"%0.2f"
,
(
$close
-
$open
)
/
$open
*
100
);
$temp
[
'high_usd'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$high
*
$this
->
basic_price
[
$coin
][
'usd'
]);
...
...
@@ -103,31 +130,36 @@ class HuobiBuilder extends FactoryService
$ticker
=
[];
for
(
$i
=
0
;
$i
<
$len
;
$i
++
)
{
$symbol
=
$this
->
redis
->
lindex
(
$this
->
supported_symbol_list
,
$i
);
list
(
$close
,
$open
)
=
$this
->
redis
->
hmget
(
$this
->
quotation_prefix
.
strtolower
(
$symbol
),
'last'
,
'open'
);
list
(
$close
,
$open
,
$low
,
$high
,
$vol
)
=
$this
->
redis
->
hmget
(
$this
->
quotation_prefix
.
strtolower
(
$symbol
),
'last'
,
'open'
,
'low'
,
'high'
,
'vol'
);
if
(
'0.00000000'
==
$close
)
continue
;
$temp
=
[];
$temp
[
'symbol'
]
=
strtoupper
(
$symbol
);
$temp
[
'close'
]
=
number_format
(
$close
,
6
,
'.'
,
''
);
$temp
[
'close'
]
=
$close
;
$temp
[
'low'
]
=
$low
;
$temp
[
'high'
]
=
$high
;
$temp
[
'open'
]
=
$open
;
$temp
[
'vol'
]
=
$vol
;
$temp
[
'change'
]
=
(
0
==
$open
)
?
0
:
(
float
)
sprintf
(
"%0.2f"
,
(
$close
-
$open
)
/
$open
*
100
);
array_push
(
$ticker
,
$temp
);
$key
=
$this
->
quotation_prefix
.
strtoupper
(
$symbol
);
$this
->
redis_ticker
->
hmset
(
$key
,
'low'
,
$low
,
'high'
,
$high
,
'last'
,
$close
,
'open'
,
$open
,
'vol'
,
$vol
);
}
$ticker_sort_close
=
$this
->
arraySort
(
$ticker
,
'close'
);
$ticker_sort_close
=
Tools
::
arraySort
(
$ticker
,
'close'
);
$this
->
redis_ticker
->
del
(
$this
->
supported_symbol_close_asc
);
$this
->
redis_ticker
->
del
(
$this
->
supported_symbol_close_desc
);
foreach
(
$ticker_sort_close
as
$val
)
{
$this
->
redis
->
lpush
(
$this
->
supported_symbol_close_sort_list
,
$val
[
'symbol'
]);
$this
->
redis_ticker
->
lpush
(
$this
->
supported_symbol_close_asc
,
strtoupper
(
$val
[
'symbol'
]));
$this
->
redis_ticker
->
rpush
(
$this
->
supported_symbol_close_desc
,
strtoupper
(
$val
[
'symbol'
]));
}
$ticker_change_close
=
$this
->
arraySort
(
$ticker
,
'change'
);
foreach
(
$ticker_change_close
as
$val
)
{
$this
->
redis
->
lpush
(
$this
->
supported_symbol_change_sort_list
,
$val
[
'symbol'
]);
}
}
protected
function
arraySort
(
$array
,
$keys
,
$sort
=
SORT_DESC
)
{
$keysValue
=
[];
foreach
(
$array
as
$k
=>
$v
)
{
$keysValue
[
$k
]
=
$v
[
$keys
];
$ticker_change_close
=
Tools
::
arraySort
(
$ticker
,
'change'
);
$this
->
redis_ticker
->
del
(
$this
->
supported_symbol_change_asc
);
$this
->
redis_ticker
->
del
(
$this
->
supported_symbol_change_desc
);
foreach
(
$ticker_change_close
as
$val
)
{
$this
->
redis_ticker
->
lpush
(
$this
->
supported_symbol_change_asc
,
strtoupper
(
$val
[
'symbol'
]));
$this
->
redis_ticker
->
rpush
(
$this
->
supported_symbol_change_desc
,
strtoupper
(
$val
[
'symbol'
]));
}
array_multisort
(
$keysValue
,
$sort
,
$array
);
return
$array
;
}
public
function
getHotTicker
()
...
...
@@ -161,14 +193,4 @@ class HuobiBuilder extends FactoryService
}
return
[
'code'
=>
$this
->
code
,
'ticker'
=>
$ticker
];
}
protected
function
sctonum
(
$num
,
$double
=
5
)
{
if
(
false
!==
stripos
(
$num
,
"e"
))
{
$a
=
explode
(
"e"
,
strtolower
(
$num
));
return
bcmul
(
$a
[
0
],
bcpow
(
10
,
$a
[
1
],
$double
),
$double
);
}
else
{
return
number_format
(
$num
,
6
,
'.'
,
''
);
}
}
}
common/service/exchange/factory/ZhaobiBuilder.php
View file @
3759c4c5
...
...
@@ -8,6 +8,7 @@
namespace
common\service\exchange\factory
;
use
common\components\Tools
;
use
linslin\yii2\curl\Curl
;
class
ZhaobiBuilder
extends
FactoryService
...
...
@@ -15,44 +16,63 @@ class ZhaobiBuilder extends FactoryService
protected
$base_url
=
'https://api.biqianbao.top'
;
protected
$supported_symbol
=
'supported_symbol_zhaobi'
;
protected
$supported_symbol_list
=
'supported_symbol_zhaobi_list'
;
protected
$supported_symbol_close_sort_list
=
'supported_symbol_close_sort_zhaobi_list'
;
protected
$supported_symbol_change_sort_list
=
'supported_symbol_change_sort_zhaobi_list'
;
protected
$supported_symbol_close_asc
=
'supported_symbol_close_asc_zhaobi'
;
protected
$supported_symbol_close_desc
=
'supported_symbol_close_desc_zhaobi'
;
protected
$supported_symbol_change_asc
=
'supported_symbol_change_asc_zhaobi'
;
protected
$supported_symbol_change_desc
=
'supported_symbol_change_desc_zhaobi'
;
protected
$quotation_prefix
=
'quotation_zhaobi_'
;
public
function
getTickerFromCache
()
public
function
getTickerFromCache
(
$page
=
1
,
$condition
=
[]
)
{
$curl
=
new
Curl
();
$api
=
$this
->
base_url
.
'/api/data/Ticker?sort=cname'
;
$res
=
$curl
->
get
(
$api
,
false
);
$ticker
=
[];
if
(
isset
(
$res
[
'message'
])
&&
'OK'
==
$res
[
'message'
])
{
$ticker_temp
=
[];
foreach
(
$res
[
'data'
]
as
$val
)
{
$ticker_temp
=
array_merge
(
$ticker_temp
,
$val
);
$this
->
start
=
0
;
$this
->
end
=
50
;
if
(
false
!=
$condition
)
{
if
(
'price'
==
$condition
[
'data_value'
])
{
if
(
'price-asc'
==
$condition
[
'sort_value'
])
{
$keys
=
$this
->
redis_ticker
->
lrange
(
$this
->
supported_symbol_close_asc
,
$this
->
start
,
$this
->
end
);
}
if
(
'price-desc'
==
$condition
[
'sort_value'
])
{
$keys
=
$this
->
redis_ticker
->
lrange
(
$this
->
supported_symbol_close_desc
,
$this
->
start
,
$this
->
end
);
}
}
foreach
(
$ticker_temp
as
$val
)
{
foreach
(
$this
->
basic_coin
as
$k
=>
$coin
)
{
$explode_arr
=
explode
(
$coin
,
$val
[
'symbol'
]);
if
(
2
==
count
(
$explode_arr
)
&&
empty
(
$explode_arr
[
1
]))
{
$temp
=
[];
$temp
[
'symbol'
]
=
(
'BCC'
==
strtoupper
(
$explode_arr
[
0
]))
?
'BCH'
.
'/'
.
$coin
:
strtoupper
(
$explode_arr
[
0
])
.
'/'
.
$coin
;
$temp
[
'currency'
]
=
(
'BCC'
==
strtoupper
(
$explode_arr
[
0
]))
?
'BCH'
:
strtoupper
(
$explode_arr
[
0
]);
$temp
[
'base_currency'
]
=
strtoupper
(
$coin
);
$temp
[
'close'
]
=
number_format
(
$val
[
'last'
],
6
,
'.'
,
''
);
if
(
'0.000000'
==
$temp
[
'close'
])
continue
;
$temp
[
'close_usd'
]
=
(
float
)
sprintf
(
"%0.6f"
,
$val
[
'last'
]
*
$this
->
basic_price
[
$coin
][
'usd'
]);
$temp
[
'close_rmb'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$val
[
'last'
]
*
$this
->
basic_price
[
$coin
][
'rmb'
]);
$temp
[
'change'
]
=
(
0
==
$val
[
'open'
])
?
0
:
(
float
)
sprintf
(
"%0.2f"
,
(
$val
[
'last'
]
-
$val
[
'open'
])
/
$val
[
'open'
]
*
100
);
$temp
[
'high_usd'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$val
[
'high'
]
*
$this
->
basic_price
[
$coin
][
'usd'
]);
$temp
[
'low_usd'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$val
[
'low'
]
*
$this
->
basic_price
[
$coin
][
'usd'
]);
$temp
[
'high_rmb'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$val
[
'high'
]
*
$this
->
basic_price
[
$coin
][
'rmb'
]);
$temp
[
'low_rmb'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$val
[
'low'
]
*
$this
->
basic_price
[
$coin
][
'rmb'
]);
$temp
[
'vol'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$val
[
'vol'
]);
$temp
[
'optional'
]
=
false
;
$temp
[
'platform_zh'
]
=
'找币'
;
$temp
[
'platform_us'
]
=
'zhaobi'
;
array_push
(
$ticker
,
$temp
);
if
(
'change'
==
$condition
[
'data_value'
])
{
if
(
'change-asc'
==
$condition
[
'sort_value'
])
{
$keys
=
$this
->
redis_ticker
->
lrange
(
$this
->
supported_symbol_change_asc
,
$this
->
start
,
$this
->
end
);
}
if
(
'change-desc'
==
$condition
[
'sort_value'
])
{
$keys
=
$this
->
redis_ticker
->
lrange
(
$this
->
supported_symbol_change_desc
,
$this
->
start
,
$this
->
end
);
}
}
}
else
{
$keys
=
$this
->
redis
->
lrange
(
$this
->
supported_symbol_list
,
$this
->
start
,
$this
->
end
);
}
$ticker
=
[];
foreach
(
$keys
as
$val
)
{
foreach
(
$this
->
basic_coin
as
$k
=>
$coin
)
{
$explode_arr
=
explode
(
$coin
,
$val
);
if
(
2
==
count
(
$explode_arr
)
&&
empty
(
$explode_arr
[
1
]))
{
if
(
false
!=
$condition
)
{
list
(
$low
,
$high
,
$close
,
$open
,
$vol
)
=
$this
->
redis_ticker
->
hmget
(
$this
->
quotation_prefix
.
strtoupper
(
$val
),
'low'
,
'high'
,
'last'
,
'open'
,
'vol'
);
}
else
{
list
(
$low
,
$high
,
$close
,
$open
,
$vol
)
=
$this
->
redis
->
hmget
(
$this
->
quotation_prefix
.
strtolower
(
$val
),
'low'
,
'high'
,
'last'
,
'open'
,
'vol'
);
}
$temp
=
[];
$temp
[
'symbol'
]
=
(
'BCC'
==
strtoupper
(
$explode_arr
[
0
]))
?
'BCH'
.
'/'
.
$coin
:
strtoupper
(
$explode_arr
[
0
])
.
'/'
.
$coin
;
$temp
[
'currency'
]
=
(
'BCC'
==
strtoupper
(
$explode_arr
[
0
]))
?
'BCH'
:
strtoupper
(
$explode_arr
[
0
]);
$temp
[
'base_currency'
]
=
strtoupper
(
$coin
);
$temp
[
'close'
]
=
$close
;
$temp
[
'close_usd'
]
=
(
float
)
sprintf
(
"%0.6f"
,
$close
*
$this
->
basic_price
[
$coin
][
'usd'
]);
$temp
[
'close_rmb'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$close
*
$this
->
basic_price
[
$coin
][
'rmb'
]);
$temp
[
'change'
]
=
(
0
==
$open
)
?
0
:
(
float
)
sprintf
(
"%0.2f"
,
(
$close
-
$open
)
/
$open
*
100
);
$temp
[
'high_usd'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$high
*
$this
->
basic_price
[
$coin
][
'usd'
]);
$temp
[
'low_usd'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$low
*
$this
->
basic_price
[
$coin
][
'usd'
]);
$temp
[
'high_rmb'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$high
*
$this
->
basic_price
[
$coin
][
'rmb'
]);
$temp
[
'low_rmb'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$low
*
$this
->
basic_price
[
$coin
][
'rmb'
]);
$temp
[
'vol'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$vol
);
$temp
[
'optional'
]
=
false
;
$temp
[
'platform_zh'
]
=
'找币'
;
$temp
[
'platform_us'
]
=
'zhaobi'
;
array_push
(
$ticker
,
$temp
);
}
}
}
...
...
@@ -79,20 +99,30 @@ class ZhaobiBuilder extends FactoryService
$ticker
=
[];
for
(
$i
=
0
;
$i
<
$len
;
$i
++
)
{
$symbol
=
$this
->
redis
->
lindex
(
$this
->
supported_symbol_list
,
$i
);
list
(
$close
,
$open
)
=
$this
->
redis
->
hmget
(
$this
->
quotation_prefix
.
strtolower
(
$symbol
),
'last'
,
'open
'
);
list
(
$close
,
$open
,
$low
,
$high
,
$vol
)
=
$this
->
redis
->
hmget
(
$this
->
quotation_prefix
.
strtolower
(
$symbol
),
'last'
,
'open'
,
'low'
,
'high'
,
'vol
'
);
$temp
=
[];
$temp
[
'symbol'
]
=
strtoupper
(
$symbol
);
$temp
[
'close'
]
=
number_format
(
$close
,
6
,
'.'
,
''
);
$temp
[
'change'
]
=
(
0
==
$open
)
?
0
:
(
float
)
sprintf
(
"%0.2f"
,
(
$close
-
$open
)
/
$open
*
100
);
array_push
(
$ticker
,
$temp
);
$key
=
$this
->
quotation_prefix
.
strtoupper
(
$symbol
);
$this
->
redis_ticker
->
hmset
(
$key
,
'low'
,
$low
,
'high'
,
$high
,
'last'
,
$close
,
'open'
,
$open
,
'vol'
,
$vol
);
}
$ticker_sort_close
=
$this
->
arraySort
(
$ticker
,
'close'
);
$ticker_sort_close
=
Tools
::
arraySort
(
$ticker
,
'close'
);
$this
->
redis_ticker
->
del
(
$this
->
supported_symbol_close_asc
);
$this
->
redis_ticker
->
del
(
$this
->
supported_symbol_close_desc
);
foreach
(
$ticker_sort_close
as
$val
)
{
$this
->
redis
->
lpush
(
$this
->
supported_symbol_close_sort_list
,
$val
[
'symbol'
]);
$this
->
redis_ticker
->
lpush
(
$this
->
supported_symbol_close_asc
,
strtoupper
(
$val
[
'symbol'
]));
$this
->
redis_ticker
->
rpush
(
$this
->
supported_symbol_close_desc
,
strtoupper
(
$val
[
'symbol'
]));
}
$ticker_change_close
=
$this
->
arraySort
(
$ticker
,
'change'
);
$ticker_change_close
=
Tools
::
arraySort
(
$ticker
,
'change'
);
$this
->
redis_ticker
->
del
(
$this
->
supported_symbol_change_asc
);
$this
->
redis_ticker
->
del
(
$this
->
supported_symbol_change_desc
);
foreach
(
$ticker_change_close
as
$val
)
{
$this
->
redis
->
lpush
(
$this
->
supported_symbol_change_sort_list
,
$val
[
'symbol'
]);
$this
->
redis_ticker
->
lpush
(
$this
->
supported_symbol_change_asc
,
strtoupper
(
$val
[
'symbol'
]));
$this
->
redis_ticker
->
rpush
(
$this
->
supported_symbol_change_desc
,
strtoupper
(
$val
[
'symbol'
]));
}
}
...
...
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