chore: Improve naming, remove unnecessary method
This commit is contained in:
@@ -197,15 +197,13 @@ def date_range(start: datetime.date, end: datetime.date):
|
|||||||
date += datetime.timedelta(days=1)
|
date += datetime.timedelta(days=1)
|
||||||
|
|
||||||
|
|
||||||
def format_date(date: datetime.date) -> str:
|
def binance_vision_zip_name(symbol: str, timeframe: str, date: datetime.date) -> str:
|
||||||
return date.strftime("%Y-%m-%d")
|
return f"{symbol}-{timeframe}-{date.strftime('%Y-%m-%d')}.zip"
|
||||||
|
|
||||||
|
|
||||||
def zip_name(symbol: str, timeframe: str, date: datetime.date) -> str:
|
def binance_vision_zip_url(
|
||||||
return f"{symbol}-{timeframe}-{format_date(date)}.zip"
|
asset_type_url_segment: str, symbol: str, timeframe: str, date: datetime.date
|
||||||
|
) -> str:
|
||||||
|
|
||||||
def zip_url(asset_type_url_segment: str, symbol: str, timeframe: str, date: datetime.date) -> str:
|
|
||||||
"""
|
"""
|
||||||
example urls:
|
example urls:
|
||||||
https://data.binance.vision/data/spot/daily/klines/BTCUSDT/1s/BTCUSDT-1s-2023-10-27.zip
|
https://data.binance.vision/data/spot/daily/klines/BTCUSDT/1s/BTCUSDT-1s-2023-10-27.zip
|
||||||
@@ -213,7 +211,7 @@ def zip_url(asset_type_url_segment: str, symbol: str, timeframe: str, date: date
|
|||||||
"""
|
"""
|
||||||
url = (
|
url = (
|
||||||
f"https://data.binance.vision/data/{asset_type_url_segment}/daily/klines/{symbol}"
|
f"https://data.binance.vision/data/{asset_type_url_segment}/daily/klines/{symbol}"
|
||||||
f"/{timeframe}/{zip_name(symbol, timeframe, date)}"
|
f"/{timeframe}/{binance_vision_zip_name(symbol, timeframe, date)}"
|
||||||
)
|
)
|
||||||
return url
|
return url
|
||||||
|
|
||||||
@@ -241,7 +239,7 @@ async def get_daily_ohlcv(
|
|||||||
:return: A dataframe containing columns date,open,high,low,close,volume
|
:return: A dataframe containing columns date,open,high,low,close,volume
|
||||||
"""
|
"""
|
||||||
|
|
||||||
url = zip_url(asset_type_url_segment, symbol, timeframe, date)
|
url = binance_vision_zip_url(asset_type_url_segment, symbol, timeframe, date)
|
||||||
|
|
||||||
logger.debug(f"download data from binance: {url}")
|
logger.debug(f"download data from binance: {url}")
|
||||||
|
|
||||||
|
|||||||
@@ -14,9 +14,9 @@ from freqtrade.enums import CandleType
|
|||||||
from freqtrade.exchange.binance_public_data import (
|
from freqtrade.exchange.binance_public_data import (
|
||||||
BadHttpStatus,
|
BadHttpStatus,
|
||||||
Http404,
|
Http404,
|
||||||
|
binance_vision_zip_name,
|
||||||
download_archive_ohlcv,
|
download_archive_ohlcv,
|
||||||
get_daily_ohlcv,
|
get_daily_ohlcv,
|
||||||
zip_name,
|
|
||||||
)
|
)
|
||||||
from freqtrade.util.datetime_helpers import dt_ts, dt_utc
|
from freqtrade.util.datetime_helpers import dt_ts, dt_utc
|
||||||
|
|
||||||
@@ -62,7 +62,7 @@ def make_daily_zip(asset_type_url_segment, symbol, timeframe, date) -> bytes:
|
|||||||
csv = df.to_csv(index=False, header=header)
|
csv = df.to_csv(index=False, header=header)
|
||||||
zip_buffer = io.BytesIO()
|
zip_buffer = io.BytesIO()
|
||||||
with zipfile.ZipFile(zip_buffer, "w") as zipf:
|
with zipfile.ZipFile(zip_buffer, "w") as zipf:
|
||||||
zipf.writestr(zip_name(symbol, timeframe, date), csv)
|
zipf.writestr(binance_vision_zip_name(symbol, timeframe, date), csv)
|
||||||
return zip_buffer.getvalue()
|
return zip_buffer.getvalue()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import os
|
|||||||
import aiohttp
|
import aiohttp
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from freqtrade.exchange.binance_public_data import zip_url
|
from freqtrade.exchange.binance_public_data import binance_vision_zip_url
|
||||||
from freqtrade.util.datetime_helpers import dt_from_ts
|
from freqtrade.util.datetime_helpers import dt_from_ts
|
||||||
|
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ class Check:
|
|||||||
first_kline_ts = first_kline[0]
|
first_kline_ts = first_kline[0]
|
||||||
date = dt_from_ts(first_kline_ts).date()
|
date = dt_from_ts(first_kline_ts).date()
|
||||||
|
|
||||||
archive_url = zip_url(
|
archive_url = binance_vision_zip_url(
|
||||||
self.asset_type_url_segment, symbol=symbol, timeframe=self.timeframe, date=date
|
self.asset_type_url_segment, symbol=symbol, timeframe=self.timeframe, date=date
|
||||||
)
|
)
|
||||||
async with self.session.get(
|
async with self.session.get(
|
||||||
|
|||||||
Reference in New Issue
Block a user