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
1aa7a3e4
Commit
1aa7a3e4
authored
Oct 18, 2019
by
shajiaiming
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/ticker' into 'master'
fix See merge request
!169
parents
d6bd61a0
7f5030da
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
15 deletions
+25
-15
HuobiBuilder.php
common/service/exchange/factory/HuobiBuilder.php
+22
-13
TickerController.php
console/controllers/TickerController.php
+3
-2
No files found.
common/service/exchange/factory/HuobiBuilder.php
View file @
1aa7a3e4
...
@@ -19,17 +19,25 @@ class HuobiBuilder extends FactoryService
...
@@ -19,17 +19,25 @@ class HuobiBuilder extends FactoryService
protected
$supported_symbol_change_sort_list
=
'supported_symbol_change_sort_huobi_list'
;
protected
$supported_symbol_change_sort_list
=
'supported_symbol_change_sort_huobi_list'
;
protected
$quotation_prefix
=
'quotation_huobi_'
;
protected
$quotation_prefix
=
'quotation_huobi_'
;
public
function
getTicker
()
public
function
hotTickerUpdate
()
{
{
$curl
=
new
Curl
();
$curl
=
new
Curl
();
$api
=
$this
->
base_url
.
'/market/tickers'
;
$res
=
$curl
->
get
(
$api
,
false
);
$symbols
=
[
if
(
isset
(
$res
[
'status'
])
&&
'ok'
==
$res
[
'status'
])
{
'btcusdt'
,
$datas
=
$res
[
'data'
];
'ethusdt'
,
foreach
(
$datas
as
$item
)
{
'eosusdt'
$key
=
$this
->
quotation_prefix
.
$item
[
'symbol'
];
];
$this
->
redis
->
hmset
(
$key
,
'low'
,
$item
[
'low'
],
'high'
,
$item
[
'high'
],
'last'
,
$item
[
'close'
],
'open'
,
$item
[
'open'
],
'vol'
,
$item
[
'vol'
]);
foreach
(
$symbols
as
$symbol
)
{
$this
->
redis
->
sadd
(
$this
->
supported_symbol
,
$item
[
'symbol'
]);
$api
=
$this
->
base_url
.
'/market/detail?symbol='
.
$symbol
;
$res
=
$curl
->
get
(
$api
,
false
);
if
(
isset
(
$res
[
'status'
])
&&
'ok'
==
$res
[
'status'
])
{
$datas
=
$res
[
'data'
];
foreach
(
$datas
as
$item
)
{
$key
=
$this
->
quotation_prefix
.
$item
[
'symbol'
];
$this
->
redis
->
hmset
(
$key
,
'low'
,
$item
[
'low'
],
'high'
,
$item
[
'high'
],
'last'
,
$item
[
'close'
],
'open'
,
$item
[
'open'
],
'vol'
,
$item
[
'vol'
]);
$this
->
redis
->
sadd
(
$this
->
supported_symbol
,
$item
[
'symbol'
]);
}
}
}
}
}
}
}
...
@@ -37,7 +45,7 @@ class HuobiBuilder extends FactoryService
...
@@ -37,7 +45,7 @@ class HuobiBuilder extends FactoryService
public
function
getTickerFromCache
(
$page
=
1
)
public
function
getTickerFromCache
(
$page
=
1
)
{
{
$size
=
0
;
$size
=
0
;
for
(
$i
=
0
;
$i
<
$page
;
$i
++
)
{
for
(
$i
=
0
;
$i
<
$page
;
$i
++
)
{
$size
+=
50
;
$size
+=
50
;
$this
->
end
=
$size
;
$this
->
end
=
$size
;
}
}
...
@@ -85,12 +93,13 @@ class HuobiBuilder extends FactoryService
...
@@ -85,12 +93,13 @@ class HuobiBuilder extends FactoryService
$data
=
[
$data
=
[
'ticker'
=>
$ticker
,
'ticker'
=>
$ticker
,
'page'
=>
[
'page'
=>
[
'pageSize'
=>
50
,
'pageSize'
=>
50
,
'currentPage'
=>
(
int
)
$page
,
'currentPage'
=>
(
int
)
$page
,
]
]
];
];
return
[
'code'
=>
$this
->
code
,
'data'
=>
$data
];
return
[
'code'
=>
$this
->
code
,
'data'
=>
$data
];
}
}
public
function
TickerSort
()
public
function
TickerSort
()
{
{
$len
=
$this
->
redis
->
llen
(
$this
->
supported_symbol_list
);
$len
=
$this
->
redis
->
llen
(
$this
->
supported_symbol_list
);
...
@@ -104,11 +113,11 @@ class HuobiBuilder extends FactoryService
...
@@ -104,11 +113,11 @@ class HuobiBuilder extends FactoryService
$temp
[
'change'
]
=
(
0
==
$open
)
?
0
:
(
float
)
sprintf
(
"%0.2f"
,
(
$close
-
$open
)
/
$open
*
100
);
$temp
[
'change'
]
=
(
0
==
$open
)
?
0
:
(
float
)
sprintf
(
"%0.2f"
,
(
$close
-
$open
)
/
$open
*
100
);
array_push
(
$ticker
,
$temp
);
array_push
(
$ticker
,
$temp
);
}
}
$ticker_sort_close
=
$this
->
arraySort
(
$ticker
,
'close'
);
$ticker_sort_close
=
$this
->
arraySort
(
$ticker
,
'close'
);
foreach
(
$ticker_sort_close
as
$val
)
{
foreach
(
$ticker_sort_close
as
$val
)
{
$this
->
redis
->
lpush
(
$this
->
supported_symbol_close_sort_list
,
$val
[
'symbol'
]);
$this
->
redis
->
lpush
(
$this
->
supported_symbol_close_sort_list
,
$val
[
'symbol'
]);
}
}
$ticker_change_close
=
$this
->
arraySort
(
$ticker
,
'change'
);
$ticker_change_close
=
$this
->
arraySort
(
$ticker
,
'change'
);
foreach
(
$ticker_change_close
as
$val
)
{
foreach
(
$ticker_change_close
as
$val
)
{
$this
->
redis
->
lpush
(
$this
->
supported_symbol_change_sort_list
,
$val
[
'symbol'
]);
$this
->
redis
->
lpush
(
$this
->
supported_symbol_change_sort_list
,
$val
[
'symbol'
]);
}
}
...
...
console/controllers/TickerController.php
View file @
1aa7a3e4
...
@@ -24,9 +24,9 @@ class TickerController extends Controller
...
@@ -24,9 +24,9 @@ class TickerController extends Controller
}
}
}
}
public
function
action
Index
()
public
function
action
Hot
()
{
{
$ticker_builder
=
ExchangeBuilderFactory
::
create
(
'Huobi'
);
$ticker_builder
=
ExchangeBuilderFactory
::
create
(
'Huobi'
);
$ticker_builder
->
getTicker
();
$ticker_builder
->
hotTickerUpdate
();
}
}
}
}
\ 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