def __init__(self, **kwargs): try: default = settings.get('SERVER').get('EX')[0] self.bestip = config.get('BESTIP').get('EX', default) except ValueError: self.bestip = ('112.74.214.43', 7727) self.client = TdxExHq_API(**kwargs)
def __init__(self, **kwargs): try: default = settings.get('SERVER').get('HQ')[0] self.bestip = config.get('BESTIP').get('HQ', default) except ValueError: self.config = None self.client = TdxHq_API(**kwargs)
def content(self, reporthook=None, downdir=None, proxies=None, chunksize=1024 * 50, *args, **kwargs): ''' 解析财务文件 :param reporthook: 钩子回调函数 :param downdir: 要解析的文件夹 :param proxies: :param chunksize: :param args: :param kwargs: :return: ''' filename = kwargs.get('filename') filesize = kwargs.get("filesize") if kwargs.get("filesize") else 0 if not filename: raise Exception("Param filename is not set") from pytdx.hq import TdxHq_API api = TdxHq_API() api.need_setup = False try: default = settings.get('SERVER').get('GP')[0][1:] bestip = config.get('BESTIP').get('GP', default) except ValueError: bestip = ("106.14.95.149", 7727) with api.connect(*bestip): content = api.get_report_file_by_size(f"tdxfin/{filename}", filesize=filesize, reporthook=reporthook) download_file = open( downdir, 'wb') if downdir else tempfile.NamedTemporaryFile( delete=True) download_file.write(content) download_file.seek(0) return download_file
def content(self, reporthook=None, downdir=None, proxies=None, chunksize=1024 * 50, *args, **kwargs): ''' 解析财务文件 :param reporthook: 钩子回调函数 :param downdir: 要解析的文件夹 :param proxies: :param chunksize: :param args: :param kwargs: :return: ''' from pytdx.hq import TdxHq_API api = TdxHq_API(**kwargs) api.need_setup = False try: default = settings.get('SERVER').get('GP')[0][1:] bestip = config.get('BESTIP').get('GP', default) except ValueError: bestip = ("106.14.95.149", 7727) with api.connect(*bestip): content = api.get_report_file_by_size("tdxfin/gpcw.txt") if downdir is None: download_file = tempfile.NamedTemporaryFile(delete=True) else: download_file = open(downdir, 'wb') download_file.write(content) download_file.seek(0) return download_file