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
41e20e62
Commit
41e20e62
authored
Aug 20, 2019
by
shajiaiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
zhaobi ticker
parent
4a5e6f8d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
3 deletions
+47
-3
ZhaobiBuilder.php
common/service/exchange/factory/ZhaobiBuilder.php
+47
-3
No files found.
common/service/exchange/factory/ZhaobiBuilder.php
View file @
41e20e62
<?php
namespace
common\service\exchange\factory
;
/**
* Created by PhpStorm.
* User: jiaming
...
...
@@ -8,7 +6,52 @@ namespace common\service\exchange\factory;
* Time: 10:10
*/
class
Zhaobi
namespace
common\service\exchange\factory
;
use
common\service\exchange\ExchangeFactory
;
use
linslin\yii2\curl\Curl
;
class
ZhaobiBuilder
{
protected
$base_url
=
'https://api.biqianbao.top'
;
protected
$base_coin
=
[
'ETH'
,
'BTC'
,
'USDT'
,
'BTC'
,
'BTY'
];
public
function
__construct
()
{
}
public
function
getTicker
()
{
$curl
=
new
Curl
();
$api
=
$this
->
base_url
.
'/api/data/Ticker?sort=cname'
;
$res
=
$curl
->
get
(
$api
,
false
);
$code
=
-
1
;
$ticker
=
[];
if
(
isset
(
$res
[
'message'
])
&&
'OK'
==
$res
[
'message'
])
{
$code
=
0
;
$ticker_temp
=
[];
foreach
(
$res
[
'data'
]
as
$val
)
{
$ticker_temp
=
array_merge
(
$ticker_temp
,
$val
);
}
foreach
(
$ticker_temp
as
$val
)
{
foreach
(
$this
->
base_coin
as
$k
=>
$coin
)
{
$explode_arr
=
explode
(
$coin
,
$val
[
'symbol'
]);
if
(
2
==
count
(
$explode_arr
)
&&
empty
(
$explode_arr
[
1
]))
{
$temp
=
[];
$temp
[
'symbol'
]
=
strtoupper
(
$explode_arr
[
0
])
.
'/'
.
$coin
;
$temp
[
'close'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$val
[
'last'
]);
$temp
[
'close_rmb'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$val
[
'lastrmb'
]);
$temp
[
'change'
]
=
(
float
)
sprintf
(
"%0.4f"
,
(
$val
[
'last'
]
-
$val
[
'open'
])
/
$val
[
'open'
]
*
100
);
$temp
[
'high'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$val
[
'high'
]);
$temp
[
'low'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$val
[
'low'
]);
$temp
[
'vol'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$val
[
'vol'
]);
array_push
(
$ticker
,
$temp
);
break
;
}
}
}
}
return
[
'code'
=>
$code
,
'ticker'
=>
$ticker
];
}
}
\ 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