hbdmapi / huobi_futures_Python

An Asynchronous Event-driven High-frequency Trading System,huobi future,huobi coin margined swap, huobi usdt margined swap included.
MIT License
267 stars 113 forks source link

example 报错 #48

Closed 18728476237 closed 3 years ago

18728476237 commented 3 years ago

python demo 下载到centos7后,按照GitHub上的Quick Start 步骤,配置了config.json中的2个KEY后,命令行运行bash run.sh,报下面的错: Traceback (most recent call last): File "main.py", line 33, in main() File "main.py", line 26, in main from alpha.quant import quant 这应该是路径的问题吗?怎么弄呢?

foonsun commented 3 years ago

是的,仍然是库导入失败,可以检查路径。最好是virtualenv 一个虚拟环境,然后在虚拟环境去运行,记得先pip 安装库,再运行试下呢。

18728476237 commented 3 years ago

大神你好,我是第一次用python,给你添麻烦了。还请赐教如下: 我的OS是centos7,已经安装好: 1、python3.6.2 2、也通过命令:pip install git+https://github.com/hbdmapi/huobi_futures_Python.git 安装好库, 3、还建好virtualenv,.virtualenv的路径是/usr/local/pycharm/virtualenv/.virtualenv/HB1 我的Win10 中python3的IDE是PyCharm2020,我通过项目导入的方式将通过GitHub拉下来的python demo项目完整导入PyCharm了, 我在PyCharm中完成以下工作: 1、配置好PyCharm 访问centos的ssh并且验证成功; 2、配置好python interpreter   3、配置好到centos的file mapping path  <Project root>→/usr/local/pycharm/virtualenvs/HB1 4、配置好 huobi_swap 文件夹中config.json中的 2个key 我要请教的是: 1、接下来我该怎么设置 PyCharm中项目的Deployment项中的Mapping项中的Deployment path项 2、我配置的PyCharm到centos的file mapping path 正确吗? 3、我是希望接下来的开发调试工作都在win10中的PyCharm中进行,我还需要做哪些工作。目前PyCharm右上角的运行、调试等按钮全部是黑色

非常感谢

------------------ 原始邮件 ------------------ 发件人: "hbdmapi/huobi_futures_Python" <notifications@github.com>; 发送时间: 2021年1月28日(星期四) 晚上7:44 收件人: "hbdmapi/huobi_futures_Python"<huobi_futures_Python@noreply.github.com>; 抄送: "宇"<525082270@qq.com>;"Author"<author@noreply.github.com>; 主题: Re: [hbdmapi/huobi_futures_Python] example 报错 (#48)

是的,仍然是库导入失败,可以检查路径。最好是virtualenv 一个虚拟环境,然后在虚拟环境去运行,记得先pip 安装库,再运行试下呢。

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

18728476237 commented 3 years ago

大神你好,上午的邮件的问题我自己解决了,请忽略。我直接运行demo test模块的websocket,报附件的错,麻烦看下,谢谢 ------------------ 原始邮件 ------------------ 发件人: "hbdmapi/huobi_futures_Python" <notifications@github.com>; 发送时间: 2021年1月28日(星期四) 晚上7:44 收件人: "hbdmapi/huobi_futures_Python"<huobi_futures_Python@noreply.github.com>; 抄送: "宇"<525082270@qq.com>;"Author"<author@noreply.github.com>; 主题: Re: [hbdmapi/huobi_futures_Python] example 报错 (#48)

是的,仍然是库导入失败,可以检查路径。最好是virtualenv 一个虚拟环境,然后在虚拟环境去运行,记得先pip 安装库,再运行试下呢。

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

foonsun commented 3 years ago

demo的是个单独的 websocket用例,可以使用pip install websockets,然后来运行就可以哈

18728476237 commented 3 years ago

我现在在看python demo的代码实现,也能通过centos7,在demo的example 中的huobi_swap路径,在命令终端输入命令bash run.sh  看到终端打印的各种实时数据。

我的问题是,HuobiSwapMarket(Websocket) 这个类没有在其它地方被使用,也没有看到process_kline(self, data)这个函数在其它地方被调用,如果我想减少Kline的打印频率,例如,将前后两个’open’的值的做个比较,大于1个usdt才打印,我该怎么做呢?

从demo代码来看,quant调用start()方法進而調用loop.run_forever()后Kline打印就實現了:

logger.info("start io loop ...", caller=self) self.loop.run_forever() 而kline具体打印内容应该是在alpha/platform/huobi_swap_market.py的HuobiSwapMarket(Websocket)的函數process_kline(self, data)實現的。字典 info中定义了Kline的打印項: async def process_kline(self, data): """ process kline data """ channel = data.get("ch") symbol = self._c_to_s[channel] d = data.get("tick") info = { "platform": self._platform, "symbol": symbol, "open": "%.8f" % d["open"], "high": "%.8f" % d["high"], "low": "%.8f" % d["low"], "close": "%.8f" % d["close"], "volume": "%.8f" % d["amount"], "timestamp": int(data.get("ts")), "kline_type": MARKET_TYPE_KLINE } kline = Kline(**info) self._klines.append(kline) SingleTask.run(self._kline_update_callback, copy.copy(kline))

logger.debug("symbol:", symbol, "kline:", kline, caller=self)

谢谢。

------------------ 原始邮件 ------------------ 发件人: "hbdmapi/huobi_futures_Python" <notifications@github.com>; 发送时间: 2021年1月30日(星期六) 上午8:04 收件人: "hbdmapi/huobi_futures_Python"<huobi_futures_Python@noreply.github.com>; 抄送: "宇"<525082270@qq.com>;"Author"<author@noreply.github.com>; 主题: Re: [hbdmapi/huobi_futures_Python] example 报错 (#48)

Closed #48.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

18728476237 commented 3 years ago

你好。我现在通过python demo 的example的huobi_swap文件夹中的代码,在centos7 的终端执行bash run.sh,可以看到实时打印的Kline。 我的问题是,应该是HuobiSwapMarket(Websocket)这个类的process_kline(self, data)方法实现了Kline的打印,我却没有在其它任何地方看到HuobiSwapMarket(Websocket)这个类被调用,也没有看到process_kline(self, data)方法被调用,我错在哪里呢?如果我要减少Kline的打印频率,例如,我将'open'的新旧值进行比较,只有大于1个usdt才打印,我该怎么做? 谢谢。

------------------ 原始邮件 ------------------ 发件人: "hbdmapi/huobi_futures_Python" <notifications@github.com>; 发送时间: 2021年1月30日(星期六) 上午7:51 收件人: "hbdmapi/huobi_futures_Python"<huobi_futures_Python@noreply.github.com>; 抄送: "宇"<525082270@qq.com>;"Author"<author@noreply.github.com>; 主题: Re: [hbdmapi/huobi_futures_Python] example 报错 (#48)

demo的是个单独的 websocket用例,可以使用pip install websockets,然后来运行就可以哈

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

18728476237 commented 3 years ago

你好。我现在通过python demo 的example的huobi_swap文件夹中的代码,在centos7 的终端执行bash run.sh,可以看到实时打印的Kline。 我的问题是,应该是HuobiSwapMarket(Websocket)这个类的process_kline(self, data)方法实现了Kline的打印,我却没有在其它任何地方看到HuobiSwapMarket(Websocket)这个类被调用,也没有看到process_kline(self, data)方法被调用,我错在哪里呢?如果我要减少Kline的打印频率,例如,我将'open'的新旧值进行比较,只有大于1个usdt才打印,我该怎么做? 谢谢。

------------------ 原始邮件 ------------------ 发件人: "hbdmapi/huobi_futures_Python" <notifications@github.com>; 发送时间: 2021年1月30日(星期六) 上午7:51 收件人: "hbdmapi/huobi_futures_Python"<huobi_futures_Python@noreply.github.com>; 抄送: "宇"<525082270@qq.com>;"Author"<author@noreply.github.com>; 主题: Re: [hbdmapi/huobi_futures_Python] example 报错 (#48)

demo的是个单独的 websocket用例,可以使用pip install websockets,然后来运行就可以哈

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.