Commit 51a6bc34 authored by 陈涛's avatar 陈涛

Update price.py

parent ca2218e6
......@@ -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()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment