adjusted function get_seed_candles() [maintaining backward compability]

This commit is contained in:
Dario Moceri
2021-02-10 22:02:50 +01:00
parent 82020263e3
commit ab1a3da851

View File

@@ -6,6 +6,7 @@ import asyncio
import aiohttp
import time
import json
import datetime
from ..utils.custom_logger import CustomLogger
from ..utils.auth import generate_auth_headers, calculate_order_flags, gen_unique_cid
@@ -71,7 +72,7 @@ class BfxRest:
# Public Data #
##################################################
async def get_seed_candles(self, symbol, start, end, tf='1d', limit=10000, sort=0):
async def get_seed_candles(self, symbol, tf='1m', start=None, end=None, limit=10000, sort=0):
"""
Get all of the seed candles between the start and end period.
# Attributes
@@ -84,6 +85,11 @@ class BfxRest:
@param sort int: if = 1 it sorts results returned with old > new
@return Array [ MTS, OPEN, CLOSE, HIGH, LOW, VOLUME ]
"""
if not start and not end:
start = 0
end = int(round((time.time() // 60 * 60) * 1000))
endpoint = f'candles/trade:{tf}:{symbol}/hist?limit={limit}&start={start}&end={end}&sort={sort}'
self.logger.info("Downloading seed candles from Bitfinex...")
candles = await self.fetch(endpoint)