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
2c3253af
Commit
2c3253af
authored
Nov 12, 2020
by
shajiaiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
接入新交易行情
parent
82e67e81
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
291 additions
and
2 deletions
+291
-2
CoinController.php
api/controllers/CoinController.php
+1
-1
TickerController.php
api/controllers/TickerController.php
+16
-0
ExchangeBusiness.php
common/business/ExchangeBusiness.php
+2
-1
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 @
2c3253af
...
...
@@ -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 @
2c3253af
...
...
@@ -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 @
2c3253af
...
...
@@ -27,7 +27,8 @@ class ExchangeBusiness
*/
private
static
$exchanges
=
[
0
=>
'Bty'
,
1
=>
'HuoBi'
,
#1 => 'HuoBi',
1
=>
'Wbf'
,
2
=>
'Hadax'
,
3
=>
'Bitfinex'
,
4
=>
'Bittrex'
,
...
...
common/service/exchange/Wbf.php
0 → 100644
View file @
2c3253af
<?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 @
2c3253af
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