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
16826dc3
Commit
16826dc3
authored
Apr 29, 2021
by
shajiaiming
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/ticker' into 'master'
Feature/ticker See merge request
!473
parents
e6a2f160
112a644f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
94 additions
and
2 deletions
+94
-2
TickerController.php
api/controllers/TickerController.php
+16
-0
ExchangeBusiness.php
common/business/ExchangeBusiness.php
+9
-2
Gwa.php
common/service/exchange/Gwa.php
+69
-0
No files found.
api/controllers/TickerController.php
View file @
16826dc3
...
@@ -386,6 +386,22 @@ class TickerController extends BaseController
...
@@ -386,6 +386,22 @@ class TickerController extends BaseController
]
]
];
];
}
}
if
(
64
==
$platform_id
)
{
$datas
=
[
[
'exchange'
=>
'huobi'
,
'symbol'
=>
[
'btcusdt'
,
'ethusdt'
],
],
[
'exchange'
=>
'gwa'
,
'symbol'
=>
[
'gwausdt'
],
]
];
}
$ticker
=
[];
$ticker
=
[];
foreach
(
$datas
as
$data
)
{
foreach
(
$datas
as
$data
)
{
$builder
=
ExchangeBuilderFactory
::
create
(
$data
[
'exchange'
]);
$builder
=
ExchangeBuilderFactory
::
create
(
$data
[
'exchange'
]);
...
...
common/business/ExchangeBusiness.php
View file @
16826dc3
...
@@ -42,7 +42,8 @@ class ExchangeBusiness
...
@@ -42,7 +42,8 @@ class ExchangeBusiness
13
=>
'Jinwang'
,
13
=>
'Jinwang'
,
14
=>
'Hd'
,
14
=>
'Hd'
,
15
=>
'Ztb'
,
15
=>
'Ztb'
,
16
=>
'Wbf'
16
=>
'Wbf'
,
17
=>
'Gwa'
//1 => 'Hadax', //不需要
//1 => 'Hadax', //不需要
//2 => 'Bitfinex', //不需要
//2 => 'Bitfinex', //不需要
...
@@ -411,6 +412,12 @@ class ExchangeBusiness
...
@@ -411,6 +412,12 @@ class ExchangeBusiness
goto
doEnd
;
goto
doEnd
;
}
}
if
(
in_array
(
strtoupper
(
$tag
),
[
'GWA'
]))
{
$exchange
=
ExchangeFactory
::
createExchange
(
"Gwa"
);
$quotation
=
$exchange
->
getTicker
(
'GWA'
,
'USDT'
);
goto
doEnd
;
}
foreach
(
self
::
$exchanges
as
$exchange
)
{
foreach
(
self
::
$exchanges
as
$exchange
)
{
/**
/**
* @var $exchange \common\service\exchange\Exchange
* @var $exchange \common\service\exchange\Exchange
...
@@ -468,7 +475,7 @@ class ExchangeBusiness
...
@@ -468,7 +475,7 @@ class ExchangeBusiness
$exchange
=
ExchangeFactory
::
createExchange
(
"Go"
);
$exchange
=
ExchangeFactory
::
createExchange
(
"Go"
);
$rate
=
$exchange
->
getTicker
(
"CNY"
,
"USD"
);
$rate
=
$exchange
->
getTicker
(
"CNY"
,
"USD"
);
$cny_usd_rate
=
1
/
$rate
[
'last'
];
$cny_usd_rate
=
1
/
$rate
[
'last'
];
if
(
in_array
(
strtoupper
(
$tag
),
[
'FOLI'
,
'CIC'
,
'ZYC'
,
'MC'
,
'KPC8'
,
'BBD'
,
'BVA'
,
'DAG'
,
'BNC'
,
'BNB'
,
'GHP'
,
'DRA'
,
'ETC'
,
'PAX'
,
'STH'
,
'XJH'
,
'SFT'
,
'TSC'
,
'SUM'
,
'USDW'
,
'FUT'
,
'MBTC'
,
'METH'
,
'GLCW'
,
'HDC'
,
'LELE'
,
'ZUE'
]))
{
if
(
in_array
(
strtoupper
(
$tag
),
[
'FOLI'
,
'CIC'
,
'ZYC'
,
'MC'
,
'KPC8'
,
'BBD'
,
'BVA'
,
'DAG'
,
'BNC'
,
'BNB'
,
'GHP'
,
'DRA'
,
'ETC'
,
'PAX'
,
'STH'
,
'XJH'
,
'SFT'
,
'TSC'
,
'SUM'
,
'USDW'
,
'FUT'
,
'MBTC'
,
'METH'
,
'GLCW'
,
'HDC'
,
'
GWA'
,
'
LELE'
,
'ZUE'
]))
{
$quotation
[
'usd'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$quotation
[
'last'
]);
$quotation
[
'usd'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$quotation
[
'last'
]);
$quotation
[
'rmb'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$quotation
[
'last'
]
/
$cny_usd_rate
);
$quotation
[
'rmb'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$quotation
[
'last'
]
/
$cny_usd_rate
);
$quotation
[
'low'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$quotation
[
'low'
]);
$quotation
[
'low'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$quotation
[
'low'
]);
...
...
common/service/exchange/Gwa.php
0 → 100644
View file @
16826dc3
<?php
/**
* Created by PhpStorm.
* User: rlgyzhcn
* Date: 18-8-7
* Time: 上午11:30
*/
namespace
common\service\exchange
;
use
linslin\yii2\curl\Curl
;
class
Gwa
extends
Exchange
implements
ExchangeInterface
{
protected
$supported_symbol
=
'supported_symbol_gwa'
;
protected
$quotation_prefix
=
'quotation_gwa_'
;
protected
$base_url
=
'https://api.gwaworld.io/getBalance'
;
public
function
symbolExists
(
$tag
=
'GWA'
,
$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
=
'GWA'
,
$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
)
&&
1
==
$res
[
'code'
])
{
$key
=
$this
->
quotation_prefix
.
'GWAUSDT'
;
$this
->
redis
->
hmset
(
$key
,
'low'
,
$res
[
'data'
][
'currPrice'
],
'high'
,
$res
[
'data'
][
'currPrice'
],
'last'
,
$res
[
'data'
][
'currPrice'
],
'change'
,
$res
[
'data'
][
'range'
]);
if
(
!
$this
->
redis
->
sismember
(
$this
->
supported_symbol
,
'GWAUSDT'
))
{
$this
->
redis
->
sadd
(
$this
->
supported_symbol
,
'GWAUSDT'
);
}
}
}
}
\ 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