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
fb742e40
Commit
fb742e40
authored
Aug 07, 2018
by
rlgy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
ab959de2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
68 additions
and
7 deletions
+68
-7
ExchangeBusiness.php
common/business/ExchangeBusiness.php
+8
-7
Bty.php
common/service/exchange/Bty.php
+60
-0
No files found.
common/business/ExchangeBusiness.php
View file @
fb742e40
...
...
@@ -23,11 +23,12 @@ class ExchangeBusiness
* @var array
*/
private
static
$exchanges
=
[
0
=>
'HuoBi'
,
1
=>
'Hadax'
,
2
=>
'Bitfinex'
,
3
=>
'Bittrex'
,
4
=>
'Zb'
,
0
=>
'Bty'
,
1
=>
'HuoBi'
,
2
=>
'Hadax'
,
3
=>
'Bitfinex'
,
4
=>
'Bittrex'
,
5
=>
'Zb'
,
];
/**
...
...
@@ -134,8 +135,8 @@ class ExchangeBusiness
$quotation
=
[];
//使用Coin服务
try
{
$coinServer
=
CoinFactory
::
createCoin
(
$row
[
'name'
],
$row
[
'id'
],
$row
[
'sid'
]);
$rows
[
$key
][
'sid'
]
=
ucfirst
(
$rows
[
$key
][
'sid'
]);
$coinServer
=
CoinFactory
::
createCoin
(
$row
[
'name'
],
$row
[
'id'
],
$row
[
'sid'
]);
$rows
[
$key
][
'sid'
]
=
ucfirst
(
$rows
[
$key
][
'sid'
]);
$rows
[
$key
][
'rmb'
]
=
$coinServer
->
getPrice
();
$rows
[
$key
][
'last'
]
=
$coinServer
->
getDollar
();
$rows
[
$key
][
'low'
]
=
$coinServer
->
getLow
();
...
...
common/service/exchange/Bty.php
0 → 100644
View file @
fb742e40
<?php
/**
* Created by PhpStorm.
* User: rlgyzhcn
* Date: 18-8-7
* Time: 上午11:30
*/
namespace
common\service\exchange
;
class
Bty
extends
Exchange
implements
ExchangeInterface
{
protected
$supported_symbol
=
'supported_symbol_bty'
;
protected
$quotation_prefix
=
'quotation_bty_'
;
protected
$base_url
=
'http://40.83.77.188/api/data/Ticker?sort=cname'
;
/**
* 转化交易对为请求变量
*
* @param string $tag
* @param string $aim
* @return mixed
*/
public
function
formatSymbol
(
$tag
=
'BTC'
,
$aim
=
'USDT'
)
{
return
strtoupper
(
$tag
.
$aim
);
}
/**
* 保存支持的交易对到redis数据库,使用crontab定时更新
* @return mixed|void
*/
public
function
setSupportedSymbol
()
{
$this
->
redis
->
sadd
(
$this
->
supported_symbol
,
'BTYUSDT'
);
}
/**
* 更新交易对行情保存到redis,使用crontab定时更新
* @return mixed|void
*/
public
function
setQuotation
()
{
$content
=
$this
->
ch
->
get
(
$this
->
base_url
,
false
);
if
(
is_array
(
$content
)
&&
isset
(
$content
[
'code'
])
&&
$content
[
'code'
]
==
200
)
{
$data
=
$content
[
'data'
][
'USDT'
];
foreach
(
$data
as
$item
)
{
if
(
$item
[
'symbol'
]
==
'BTYUSDT'
)
{
$data
=
$item
;
break
;
}
}
$key
=
$this
->
quotation_prefix
.
'BTYUSDT'
;
$this
->
redis
->
hmset
(
$key
,
'low'
,
$data
[
'low'
],
'high'
,
$data
[
'high'
],
'last'
,
$data
[
'last'
],
'rmb'
,
$data
[
'lastrmb'
]);
$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