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
e8d2dd8c
Commit
e8d2dd8c
authored
Aug 26, 2019
by
shajiaiming
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/ticker' into 'master'
添加币安行情 See merge request
!99
parents
7e7c9aa0
fbe5bd3d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
0 deletions
+52
-0
Binance.php
common/service/exchange/Binance.php
+52
-0
No files found.
common/service/exchange/Binance.php
0 → 100644
View file @
e8d2dd8c
<?php
/**
* Created by PhpStorm.
* User: rlgyzhcn
* Date: 18-6-26
* Time: 下午7:21
*/
namespace
common\service\exchange
;
use
Yii
;
use
linslin\yii2\curl\Curl
;
class
Binance
extends
Exchange
implements
ExchangeInterface
{
protected
$supported_symbol
=
'supported_symbol_binance'
;
protected
$quotation_prefix
=
'quotation_binance_'
;
protected
$base_url
=
'https://api.binance.com'
;
public
function
formatSymbol
(
$tag
=
'BTC'
,
$aim
=
'USDT'
)
{
return
strtolower
(
trim
(
$tag
)
.
trim
(
$aim
));
}
public
function
setSupportedSymbol
()
{
$curl
=
new
Curl
();
$api
=
$this
->
base_url
.
'/api/v1/ticker/24hr'
;
$res
=
$curl
->
get
(
$api
,
false
);
//json
if
(
is_array
(
$res
))
{
foreach
(
$res
as
$item
)
{
$this
->
redis
->
sadd
(
$this
->
supported_symbol
,
strtolower
(
$item
[
'symbol'
]));
}
}
}
public
function
setQuotation
()
{
$curl
=
new
Curl
();
$api
=
$this
->
base_url
.
'/api/v1/ticker/24hr'
;
$res
=
$curl
->
get
(
$api
,
false
);
if
(
is_array
(
$res
))
{
foreach
(
$res
as
$item
)
{
$key
=
$this
->
quotation_prefix
.
strtolower
(
$item
[
'symbol'
]);
$this
->
redis
->
hmset
(
$key
,
'low'
,
$item
[
'lowPrice'
],
'high'
,
$item
[
'highPrice'
],
'last'
,
$item
[
'lastPrice'
],
'open'
,
$item
[
'openPrice'
]);
$this
->
redis
->
sadd
(
$this
->
supported_symbol
,
$item
[
'symbol'
]);
}
}
}
}
\ No newline at end of file
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