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
69c97b4f
Commit
69c97b4f
authored
Sep 11, 2019
by
shajiaiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
自选逻辑调整
parent
ef00564c
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
19 deletions
+19
-19
TickerController.php
api/controllers/TickerController.php
+13
-1
BinanceBuilder.php
common/service/exchange/factory/BinanceBuilder.php
+2
-6
HuobiBuilder.php
common/service/exchange/factory/HuobiBuilder.php
+2
-6
ZhaobiBuilder.php
common/service/exchange/factory/ZhaobiBuilder.php
+2
-6
No files found.
api/controllers/TickerController.php
View file @
69c97b4f
...
...
@@ -8,6 +8,7 @@ use api\base\BaseController;
use
common\models\psources\CoinOptional
;
use
common\service\exchange\ExchangeFactory
;
use
common\service\exchange\ExchangeBuilderFactory
;
use
yii\helpers\ArrayHelper
;
class
TickerController
extends
BaseController
{
...
...
@@ -48,9 +49,20 @@ class TickerController extends BaseController
goto
doEnd
;
}
$builder
=
ExchangeBuilderFactory
::
create
(
$exchange
);
$result
=
$builder
->
getTicker
(
$device_code
);
$result
=
$builder
->
getTicker
();
$code
=
$result
[
'code'
];
$data
=
$result
[
'ticker'
];
if
(
false
!=
$device_code
)
{
$coin_optional
=
CoinOptional
::
find
()
->
select
(
'symbol'
)
->
where
([
'platform'
=>
$exchange
,
'device_code'
=>
$device_code
])
->
asArray
()
->
all
();
$coin_optional
=
ArrayHelper
::
getColumn
(
$coin_optional
,
'symbol'
);
foreach
(
$data
as
&
$val
)
{
if
(
in_array
(
$val
[
'symbol'
],
$coin_optional
))
{
$val
[
'optional'
]
=
true
;
}
}
}
$msg
=
'success'
;
doEnd
:
...
...
common/service/exchange/factory/BinanceBuilder.php
View file @
69c97b4f
...
...
@@ -14,7 +14,7 @@ class BinanceBuilder extends FactoryService
{
protected
$base_url
=
'https://api.binance.com'
;
public
function
getTicker
(
$device_code
=
''
)
public
function
getTicker
()
{
$curl
=
new
Curl
();
$api
=
$this
->
base_url
.
'/api/v1/ticker/24hr'
;
...
...
@@ -36,11 +36,7 @@ class BinanceBuilder extends FactoryService
$temp
[
'high'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$val
[
'highPrice'
]);
$temp
[
'low'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$val
[
'lowPrice'
]);
$temp
[
'vol'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$val
[
'volume'
]);
if
(
false
!=
$device_code
&&
\Yii
::
$app
->
redis_app
->
sismember
(
$device_code
.
'_binance'
,
$val
[
'symbol'
]))
{
$temp
[
'optional'
]
=
true
;
}
else
{
$temp
[
'optional'
]
=
false
;
}
$temp
[
'optional'
]
=
false
;
array_push
(
$ticker
,
$temp
);
break
;
}
...
...
common/service/exchange/factory/HuobiBuilder.php
View file @
69c97b4f
...
...
@@ -14,7 +14,7 @@ class HuobiBuilder extends FactoryService
{
protected
$base_url
=
'https://api.huobi.pro'
;
public
function
getTicker
(
$device_code
=
''
)
public
function
getTicker
()
{
$curl
=
new
Curl
();
$api
=
$this
->
base_url
.
'/market/tickers'
;
...
...
@@ -36,11 +36,7 @@ class HuobiBuilder extends FactoryService
$temp
[
'high'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$val
[
'high'
]);
$temp
[
'low'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$val
[
'low'
]);
$temp
[
'vol'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$val
[
'vol'
]);
if
(
false
!=
$device_code
&&
\Yii
::
$app
->
redis_app
->
sismember
(
$device_code
.
'_huobi'
,
$val
[
'symbol'
]))
{
$temp
[
'optional'
]
=
true
;
}
else
{
$temp
[
'optional'
]
=
false
;
}
$temp
[
'optional'
]
=
false
;
array_push
(
$ticker
,
$temp
);
break
;
}
...
...
common/service/exchange/factory/ZhaobiBuilder.php
View file @
69c97b4f
...
...
@@ -14,7 +14,7 @@ class ZhaobiBuilder extends FactoryService
{
protected
$base_url
=
'https://api.biqianbao.top'
;
public
function
getTicker
(
$device_code
=
''
)
public
function
getTicker
()
{
$curl
=
new
Curl
();
$api
=
$this
->
base_url
.
'/api/data/Ticker?sort=cname'
;
...
...
@@ -40,11 +40,7 @@ class ZhaobiBuilder extends FactoryService
$temp
[
'high'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$val
[
'high'
]);
$temp
[
'low'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$val
[
'low'
]);
$temp
[
'vol'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$val
[
'vol'
]);
if
(
false
!=
$device_code
&&
\Yii
::
$app
->
redis_app
->
sismember
(
$device_code
.
'_zhaobi'
,
$val
[
'symbol'
]))
{
$temp
[
'optional'
]
=
true
;
}
else
{
$temp
[
'optional'
]
=
false
;
}
$temp
[
'optional'
]
=
false
;
array_push
(
$ticker
,
$temp
);
break
;
}
...
...
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