在StreamingForexPrices
内调用stream_to_stop()
时遇到一些问题。。以下代码给出了此错误:
TypeError: unbound method stream_to_stop() must be called with StreamingForexPrices instance as first argument (got int instance instead)
有人能帮我理解吗?谢谢
class StreamingForexPrices(object):
def __init__(
self, domain, access_token,
account_id, instruments, events_queue
):
self.domain = domain
self.access_token = access_token
self.account_id = account_id
self.instruments = instruments
self.events_queue = events_queue
def stream_to_stop(self):
response = self.connect_to_stream()
if response.status_code != 200:
return
for line in response.iter_lines(1):
if line:
try:
msg = json.loads(line)
except Exception as e:
print "Caught exception when converting message into json\n" + str(e)
return
if msg.has_key("instrument") or msg.has_key("tick"):
print msg["tick"]["ask"] - .001
instrument = msg["tick"]["instrument"]
time = msg["tick"]["time"]
bid = msg["tick"]["bid"]
ask = msg["tick"]["ask"]
stopLoss = msg["tick"]["ask"] - .001
tev = StopEvent(stopLoss)
self.events_queue.put(tev)
stop = StreamingForexPrices.stream_to_stop()
print stop
我的目标是将流的输出输出输出到\u stop。。再次感谢!你知道吗
已编辑缩进。。你知道吗
How to use python class
相关问题 更多 >
编程相关推荐