Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
PyFund
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
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
陈涛
PyFund
Commits
51a6bc34
Commit
51a6bc34
authored
Nov 12, 2024
by
陈涛
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update price.py
parent
ca2218e6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
3 deletions
+4
-3
price.py
service/price.py
+4
-3
No files found.
service/price.py
View file @
51a6bc34
...
...
@@ -21,7 +21,7 @@ class CMCPrice:
self
.
mongodb_manager
=
mongodb_manager
self
.
cmc_map
=
None
self
.
proxies
=
settings
.
cmc_proxy
self
.
quick_search_url
=
'https://
web
-api.coinmarketcap.com/v1/cryptocurrency/map'
self
.
quick_search_url
=
'https://
pro
-api.coinmarketcap.com/v1/cryptocurrency/map'
self
.
cmc_api_key
=
"99ddd4c0-561c-4e7a-b579-d9ded29b6ba0"
self
.
use_api_key
=
False
self
.
per_request_limit
=
10000
# number [ 1 .. 10000 ]
...
...
@@ -38,7 +38,8 @@ class CMCPrice:
async
def
get_quick_search_map
(
self
,
from_cache
=
True
):
if
not
from_cache
:
headers
=
{
'User-Agent'
:
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36'
'User-Agent'
:
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36'
,
'X-CMC_PRO_API_KEY'
:
self
.
cmc_api_key
}
response
=
await
aio_request
(
url
=
self
.
quick_search_url
,
proxies
=
self
.
proxies
,
headers
=
headers
)
data
=
{
item
[
'symbol'
]:
item
for
item
in
response
[
'data'
]}
...
...
@@ -118,7 +119,7 @@ class CMCPrice:
:return:
"""
await
self
.
init
()
url
=
f
'https://
web
-api.coinmarketcap.com/v2/cryptocurrency/ohlcv/historical?interval=1h&time_period=hourly&count={count}&symbol={symbol}&time_start={int(start_time.timestamp())}'
url
=
f
'https://
pro
-api.coinmarketcap.com/v2/cryptocurrency/ohlcv/historical?interval=1h&time_period=hourly&count={count}&symbol={symbol}&time_start={int(start_time.timestamp())}'
error
=
''
# 过滤数据在开始和结束时间范围内
end_time
=
self
.
get_now_hour
()
...
...
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