51bitquant / howtrader

Howtrader: A crypto quant framework for developing, backtesting, and executing your own trading strategies. Seamlessly integrates with TradingView and other third-party signals. Simply send a post request to automate trading and order placement. Supports Binance and Okex exchanges.
MIT License
665 stars 288 forks source link

使用新增的okx接口,登录时调用query_open_orders函数,总是报超时的错误 #35

Open BaoChunhui opened 11 months ago

BaoChunhui commented 11 months ago

登录时会调用query_open_orders函数,总是报错超时,初步debug发现是sign中的msg不对,修改sign函数如下 def sign(self, request: Request) -> Request: """signature"""

    now: datetime = datetime.utcnow()
    now = now - timedelta(milliseconds=self.time_offset_ms)
    timestamp: str = now.isoformat("T", "milliseconds") + "Z"

    if request.params:
        path: str = request.path + "?" + urlencode(request.params)
    else:
        path: str = request.path

    if request.data:
        request.data = json.dumps(request.data)
        msg: str = timestamp + request.method + path + request.data
    else:
        msg: str = timestamp + request.method + path

    signature: bytes = generate_signature(msg, self.secret)

问题依然没有解决,怀疑取到timestamp之后过了很久才向服务器发送请求