Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python TypeError:不支持*:';instancemethod';和';int';_Python - Fatal编程技术网

Python TypeError:不支持*:';instancemethod';和';int';

Python TypeError:不支持*:';instancemethod';和';int';,python,Python,我正在尝试调试一些Python(对该语言几乎一无所知)。在某些代码中,有一行: self.min_spread = self.exchange.account.get_fee * 2 这将返回错误: Traceback (most recent call last): File "launch.py", line 33, in <module> main() File "launch.py", line 28, in main bot = marketmak

我正在尝试调试一些Python(对该语言几乎一无所知)。在某些代码中,有一行:

self.min_spread = self.exchange.account.get_fee * 2
这将返回错误:

Traceback (most recent call last):
  File "launch.py", line 33, in <module>
    main()
  File "launch.py", line 28, in main
    bot = marketmaker.MarketMaker(exchange, pair)
  File "T:\mm-1.01\src\strategies\marketmaker.py", line 22, in __init__
    self.min_spread = self.exchange.account.get_fee * 2
TypeError: unsupported operand type(s) for *: 'instancemethod' and 'int'
编辑:

以下是account类:

class Account():


    def __init__(self, agent):
        self.agent = agent
        self._account()

    def _account(self):
        pass

    def get_balance(self):
        self._update_balance()
        return self.balance

    def get_fee(self):
        return self.get_fee

    def get_open_orders(self):
        self._update_open_orders()
        return self.open_orders

    def cancel(self, order_id):
        pass

    def cancel_all(self, order_type='all'):
        if order_type == 'all':
            for order in self.get_open_orders():
                self.cancel(order['order_id'])
        else:
            for order in self.get_open_orders():
                if order['type'] == order_type:
                    self.cancel(order['order_id'])

似乎您忘记了在函数调用之后添加
()
,因此:

self.exchange.account.get_fee() * 2
经过进一步研究,您的函数本身似乎存在一个问题:

def get_fee(self):
    return self.get_fee

现在它返回self.get\u fee这是一个实例方法,它不返回任何值。这就是为什么会出现错误。

似乎忘记在函数调用之后添加
()
,因此:

self.exchange.account.get_fee() * 2
经过进一步研究,您的函数本身似乎存在一个问题:

def get_fee(self):
    return self.get_fee


现在它返回self.get\u fee这是一个实例方法,它不返回任何值。这就是您出错的原因。

不需要任何输入吗?发布整个课程。否则就很难说了,因为你的函数可能需要参数。我不这么认为,尽管我不懂这里的内容,因为我不会讲Python。这个方法对我来说毫无意义(C#dev),它被定义为def get#u fee(self):return self.get#fee噢,天哪,instancemethod正在返回它自己。那是你的问题。它应该返回一个float。也许程序员的意思是def get_fee(self):return self.fee。。instead@RBT制作另一个完全模仿你的so
分类类和个人类的类怎么样?不
self.exchange.account.get_fee()
需要任何输入吗?发布整个类。否则就很难说了,因为你的函数可能需要参数。我不这么认为,尽管我不懂这里的内容,因为我不会讲Python。这个方法对我来说毫无意义(C#dev),它被定义为def get#u fee(self):return self.get#fee噢,天哪,instancemethod正在返回它自己。那是你的问题。它应该返回一个float。也许程序员的意思是def get_fee(self):return self.fee。。instead@RBT制作另一个完全模仿你的so
分类和个人的类怎么样class@KDawG那么这需要更多的研究。我们需要查看整个课程。谢谢大家,我已经发布了Account类。@RBT行
self.exchange.Account.get_fee()
?我正在停车。这是我昨天买的一个机器人,但它不适合使用。@KDawG那么这需要更多的研究。我们需要查看整个课程。谢谢大家,我已经发布了Account类。@RBT行
self.exchange.Account.get_fee()
?我正在停车。这是我昨天买的机器人,但它不适合我的用途。