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
25f35cc8
Commit
25f35cc8
authored
Nov 12, 2020
by
shajiaiming
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/ticker' into 'master'
Feature/ticker See merge request
!405
parents
82e67e81
6eaa2453
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
306 additions
and
17 deletions
+306
-17
CoinController.php
api/controllers/CoinController.php
+1
-1
TickerController.php
api/controllers/TickerController.php
+16
-0
ExchangeBusiness.php
common/business/ExchangeBusiness.php
+17
-16
Wbf.php
common/service/exchange/Wbf.php
+71
-0
WbfBuilder.php
common/service/exchange/factory/WbfBuilder.php
+201
-0
No files found.
api/controllers/CoinController.php
View file @
25f35cc8
...
...
@@ -414,7 +414,7 @@ class CoinController extends BaseController
$request
=
Yii
::
$app
->
request
;
$platform
=
$request
->
post
(
'platform'
,
''
);
if
(
$platform
)
{
$brower_url
=
Yii
::
$app
->
redis
->
hget
(
'platform_brower_info'
,
$platform
);
$brower_url
=
Yii
::
$app
->
redis
->
hget
(
'platform_brower_info'
,
strtolower
(
$platform
)
);
return
[
'code'
=>
0
,
'data'
=>
$brower_url
];
}
else
{
return
[
'code'
=>
1
,
'data'
=>
[],
'msg'
=>
'平台参数不能为空'
];
...
...
api/controllers/TickerController.php
View file @
25f35cc8
...
...
@@ -335,6 +335,22 @@ class TickerController extends BaseController
]
];
}
if
(
53
==
$platform_id
)
{
$datas
=
[
[
'exchange'
=>
'huobi'
,
'symbol'
=>
[
'btcusdt'
,
'ethusdt'
],
],
[
'exchange'
=>
'wbf'
,
'symbol'
=>
[
'leleusdt'
],
]
];
}
$ticker
=
[];
foreach
(
$datas
as
$data
)
{
$builder
=
ExchangeBuilderFactory
::
create
(
$data
[
'exchange'
]);
...
...
common/business/ExchangeBusiness.php
View file @
25f35cc8
...
...
@@ -27,26 +27,21 @@ class ExchangeBusiness
*/
private
static
$exchanges
=
[
0
=>
'Bty'
,
1
=>
'HuoBi'
,
#1 => 'HuoBi',
1
=>
'Wbf'
,
2
=>
'Hadax'
,
3
=>
'Bitfinex'
,
4
=>
'Bittrex'
,
5
=>
'Zb'
,
6
=>
'Token7'
,
7
=>
'Zg'
,
8
=>
'Go'
,
9
=>
'Zhaobi'
,
10
=>
'Ex'
,
11
=>
'Zt'
,
12
=>
'Tsc'
,
13
=>
'Binance'
,
14
=>
'Bilaxy'
,
15
=>
'Bitnasdaq'
,
16
=>
'Dag'
,
17
=>
'Coinka'
,
18
=>
'Isummit'
,
19
=>
'Boc'
,
20
=>
'Jinwang'
6
=>
'Zg'
,
7
=>
'Go'
,
8
=>
'Zhaobi'
,
9
=>
'Binance'
,
10
=>
'Bilaxy'
,
11
=>
'Bitnasdaq'
,
12
=>
'Isummit'
,
13
=>
'Boc'
,
14
=>
'Jinwang'
//1 => 'Hadax', //不需要
//2 => 'Bitfinex', //不需要
...
...
@@ -58,6 +53,12 @@ class ExchangeBusiness
//7 => 'Gdpro',//已挂
//8 => 'Ceohk', //已挂
//14 => 'Biki',//已挂
// 6 => 'Token7',//已挂
// 10 => 'Ex',//已挂
// 11 => 'Zt',//已挂
// 12 => 'Tsc',//已挂
// 16 => 'Dag',//已挂
// 17 => 'Coinka',//已挂
];
/**
...
...
common/service/exchange/Wbf.php
0 → 100644
View file @
25f35cc8
<?php
/**
* Created by PhpStorm.
* User: rlgyzhcn
* Date: 18-8-7
* Time: 上午11:30
*/
namespace
common\service\exchange
;
use
linslin\yii2\curl\Curl
;
class
Wbf
extends
Exchange
implements
ExchangeInterface
{
protected
$supported_symbol
=
'supported_symbol_wbf'
;
protected
$quotation_prefix
=
'quotation_wbf_'
;
protected
$base_url
=
'https://openapi.wbf.live/open/api/get_allticker'
;
public
function
symbolExists
(
$tag
=
'LELE'
,
$aim
=
"USDT"
)
{
$supported
=
$this
->
redis
->
smembers
(
$this
->
supported_symbol
);
if
(
is_array
(
$supported
)
&&
in_array
(
$this
->
formatSymbol
(
$tag
,
$aim
),
$supported
))
{
return
true
;
}
return
false
;
}
/**
* 转化交易对为请求变量
*
* @param string $tag
* @param string $aim
* @return mixed
*/
public
function
formatSymbol
(
$tag
=
'LELE'
,
$aim
=
'USDT'
)
{
return
strtoupper
(
$tag
.
$aim
);
}
/**
* 保存支持的交易对到redis数据库,使用crontab定时更新
*
* @return mixed|void
*/
public
function
setSupportedSymbol
()
{
}
/**
* 更新交易对行情保存到redis,使用crontab定时更新
*
* @return mixed|void
*/
public
function
setQuotation
()
{
$curl
=
new
Curl
();
$res
=
$curl
->
get
(
$this
->
base_url
,
false
);
if
(
is_array
(
$res
)
&&
isset
(
$res
[
'data'
]))
{
$data
=
$res
[
'data'
][
'ticker'
];
foreach
(
$data
as
$item
)
{
$key
=
$this
->
quotation_prefix
.
strtoupper
(
$item
[
'symbol'
]);
$this
->
redis
->
hmset
(
$key
,
'low'
,
$item
[
'low'
],
'high'
,
$item
[
'high'
],
'last'
,
$item
[
'last'
],
'vol'
,
$item
[
'vol'
],
'change'
,
$item
[
'change'
]);
if
(
!
$this
->
redis
->
sismember
(
$this
->
supported_symbol
,
strtoupper
(
$item
[
'symbol'
]))){
$this
->
redis
->
sadd
(
$this
->
supported_symbol
,
strtoupper
(
$item
[
'symbol'
]));
}
}
}
}
}
\ No newline at end of file
common/service/exchange/factory/WbfBuilder.php
0 → 100644
View file @
25f35cc8
This diff is collapsed.
Click to expand it.
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