mirror of
https://github.com/freqtrade/freqtrade.git
synced 2026-01-31 11:20:24 +00:00
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)
|
||||
|
||||
|
||||
def format_date(date: datetime.date) -> str:
|
||||
return date.strftime("%Y-%m-%d")
|
||||
def binance_vision_zip_name(symbol: str, timeframe: str, date: datetime.date) -> str:
|
||||
return f"{symbol}-{timeframe}-{date.strftime('%Y-%m-%d')}.zip"
|
||||
|
||||
|
||||
def zip_name(symbol: str, timeframe: str, date: datetime.date) -> str:
|
||||
return f"{symbol}-{timeframe}-{format_date(date)}.zip"
|
||||
|
||||
|
||||
def zip_url(asset_type_url_segment: str, symbol: str, timeframe: str, date: datetime.date) -> str:
|
||||
def binance_vision_zip_url(
|
||||
asset_type_url_segment: str, symbol: str, timeframe: str, date: datetime.date
|
||||
) -> str:
|
||||
"""
|
||||
example urls:
|
||||
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 = (
|
||||
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
|
||||
|
||||
@@ -241,7 +239,7 @@ async def get_daily_ohlcv(
|
||||
: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}")
|
||||
|
||||
|
||||
@@ -14,9 +14,9 @@ from freqtrade.enums import CandleType
|
||||
from freqtrade.exchange.binance_public_data import (
|
||||
BadHttpStatus,
|
||||
Http404,
|
||||
binance_vision_zip_name,
|
||||
download_archive_ohlcv,
|
||||
get_daily_ohlcv,
|
||||
zip_name,
|
||||
)
|
||||
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)
|
||||
zip_buffer = io.BytesIO()
|
||||
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()
|
||||
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ import os
|
||||
import aiohttp
|
||||
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
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ class Check:
|
||||
first_kline_ts = first_kline[0]
|
||||
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
|
||||
)
|
||||
async with self.session.get(
|
||||
|
||||
Reference in New Issue
Block a user