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
322e8854
Commit
322e8854
authored
Sep 15, 2020
by
shajiaiming
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/ticker' into 'master'
fix See merge request
!389
parents
bc76b3ca
2755cf58
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
21 deletions
+22
-21
Bitnasdaq.php
common/service/exchange/Bitnasdaq.php
+10
-11
BitnasdaqBuilder.php
common/service/exchange/factory/BitnasdaqBuilder.php
+12
-10
No files found.
common/service/exchange/Bitnasdaq.php
View file @
322e8854
...
...
@@ -36,18 +36,17 @@ class Bitnasdaq extends Exchange implements ExchangeInterface
if
(
is_array
(
$res
)
&&
isset
(
$res
[
'data'
]))
{
$data
=
$res
[
'data'
][
'ticker'
];
foreach
(
$data
as
$key
=>
$item
)
{
if
(
strpos
(
strtoupper
(
$key
),
'_CNYT'
)
!==
false
)
{
continue
;
if
(
in_array
(
strtoupper
(
$item
[
'symbol'
]),
[
'BNCUSAT'
,
'BTCUSAT'
,
'ETCUSAT'
,
'ETHUSAT'
,
'GHPUSAT'
,
'LTCUSAT'
]))
{
$low
=
isset
(
$item
[
'low'
])
?
$item
[
'low'
]
:
0
;
$high
=
isset
(
$item
[
'high'
])
?
$item
[
'high'
]
:
0
;
$last
=
isset
(
$item
[
'last'
])
?
$item
[
'last'
]
:
0
;
$open
=
isset
(
$item
[
'last'
])
?
$item
[
'last'
]
:
0
;
$vol
=
isset
(
$item
[
'vol'
])
?
$item
[
'vol'
]
:
0
;
$change
=
isset
(
$item
[
'rose'
])
?
$item
[
'rose'
]
:
0
;
$cache_key
=
strtolower
(
$this
->
quotation_prefix
.
$item
[
'symbol'
]);
$this
->
redis
->
hmset
(
$cache_key
,
'low'
,
$low
,
'high'
,
$high
,
'last'
,
$last
,
'open'
,
$open
,
'vol'
,
$vol
,
'change'
,
$change
);
$this
->
redis
->
sadd
(
$this
->
supported_symbol
,
strtoupper
(
$item
[
'symbol'
]));
}
$low
=
isset
(
$item
[
'low'
])
?
$item
[
'low'
]
:
0
;
$high
=
isset
(
$item
[
'high'
])
?
$item
[
'high'
]
:
0
;
$last
=
isset
(
$item
[
'last'
])
?
$item
[
'last'
]
:
0
;
$open
=
isset
(
$item
[
'last'
])
?
$item
[
'last'
]
:
0
;
$vol
=
isset
(
$item
[
'vol'
])
?
$item
[
'vol'
]
:
0
;
$change
=
isset
(
$item
[
'rose'
])
?
$item
[
'rose'
]
:
0
;
$cache_key
=
strtolower
(
$this
->
quotation_prefix
.
$item
[
'symbol'
]);
$this
->
redis
->
hmset
(
$cache_key
,
'low'
,
$low
,
'high'
,
$high
,
'last'
,
$last
,
'open'
,
$open
,
'vol'
,
$vol
,
'change'
,
$change
);
$this
->
redis
->
sadd
(
$this
->
supported_symbol
,
strtoupper
(
$item
[
'symbol'
]));
}
}
}
...
...
common/service/exchange/factory/BitnasdaqBuilder.php
View file @
322e8854
...
...
@@ -62,7 +62,8 @@ class BitnasdaqBuilder extends FactoryService
$ticker
=
[];
foreach
(
$keys
as
$val
)
{
foreach
(
$this
->
basic_coin
as
$k
=>
$coin
)
{
$explode_arr
=
explode
(
strtoupper
(
$coin
),
strtoupper
(
$val
));
$temp_symbol
=
str_replace
(
'USAT'
,
'USDT'
,
$val
);
$explode_arr
=
explode
(
strtoupper
(
$coin
),
strtoupper
(
$temp_symbol
));
if
(
2
==
count
(
$explode_arr
)
&&
empty
(
$explode_arr
[
1
]))
{
if
(
false
!=
$condition
)
{
list
(
$low
,
$high
,
$close
,
$open
,
$vol
,
$change
)
=
$this
->
redis_ticker
->
hmget
(
$this
->
quotation_prefix
.
strtoupper
(
$val
),
'low'
,
'high'
,
'last'
,
'open'
,
'vol'
,
'change'
);
...
...
@@ -70,9 +71,9 @@ class BitnasdaqBuilder extends FactoryService
list
(
$low
,
$high
,
$close
,
$open
,
$vol
,
$change
)
=
$this
->
redis
->
hmget
(
$this
->
quotation_prefix
.
strtolower
(
$val
),
'low'
,
'high'
,
'last'
,
'open'
,
'vol'
,
'change'
);
}
$temp
=
[];
$temp
[
'symbol'
]
=
strtoupper
(
$explode_arr
[
0
])
.
'/
'
.
$coin
;
$temp
[
'symbol'
]
=
strtoupper
(
$explode_arr
[
0
])
.
'/
USAT'
;
$temp
[
'currency'
]
=
strtoupper
(
$explode_arr
[
0
]);
$temp
[
'base_currency'
]
=
strtoupper
(
$coin
)
;
$temp
[
'base_currency'
]
=
'USAT'
;
$temp
[
'close'
]
=
rtrim
(
sprintf
(
'%.8f'
,
floatval
(
$close
)),
'0'
);
$temp
[
'close_usd'
]
=
rtrim
(
sprintf
(
'%.6f'
,
floatval
(
$close
*
$this
->
basic_price
[
$coin
][
'usd'
])),
'0'
);
$temp
[
'close_rmb'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$close
*
$this
->
basic_price
[
$coin
][
'rmb'
]);
...
...
@@ -111,12 +112,13 @@ class BitnasdaqBuilder extends FactoryService
$temp
=
[];
$temp
[
'symbol'
]
=
strtoupper
(
$symbol
);
$temp
[
'close'
]
=
$close
;
foreach
(
$this
->
basic_coin
as
$k
=>
$coin
)
{
$explode_arr
=
explode
(
strtoupper
(
$coin
),
strtoupper
(
$symbol
));
if
(
2
==
count
(
$explode_arr
)
&&
empty
(
$explode_arr
[
1
]))
{
$temp
[
'close_rmb'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$close
*
$this
->
basic_price
[
$coin
][
'rmb'
]);
}
}
//为什么要加close_rmb作为排序
// foreach ($this->basic_coin as $k => $coin) {
// $explode_arr = explode(strtoupper($coin), strtoupper($symbol));
// if (2 == count($explode_arr) && empty($explode_arr[1])) {
// $temp['close_rmb'] = (float)sprintf("%0.4f", $close * $this->basic_price[$coin]['rmb']);
// }
// }
$temp
[
'low'
]
=
$low
;
$temp
[
'high'
]
=
$high
;
$temp
[
'open'
]
=
$open
;
...
...
@@ -127,7 +129,7 @@ class BitnasdaqBuilder extends FactoryService
$this
->
redis_ticker
->
hmset
(
$key
,
'low'
,
$low
,
'high'
,
$high
,
'last'
,
$close
,
'open'
,
$open
,
'vol'
,
$vol
,
'change'
,
$change
);
}
$ticker_sort_close
=
Tools
::
arraySort
(
$ticker
,
'close
_rmb
'
);
$ticker_sort_close
=
Tools
::
arraySort
(
$ticker
,
'close'
);
$this
->
redis_ticker
->
del
(
$this
->
supported_symbol_close_asc
);
$this
->
redis_ticker
->
del
(
$this
->
supported_symbol_close_desc
);
foreach
(
$ticker_sort_close
as
$val
)
{
...
...
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