Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: 'NoneType' object is not subscriptable #133

Closed
CryptoKong opened this issue May 23, 2018 · 4 comments · Fixed by #140
Closed

TypeError: 'NoneType' object is not subscriptable #133

CryptoKong opened this issue May 23, 2018 · 4 comments · Fixed by #140

Comments

@CryptoKong
Copy link

CryptoKong commented May 23, 2018

Expected Behavior

Strategy to start

Actual Behavior

Worker places all buy and sell orders but gives error then cancels all orders. I think this is because orders were filled before it finished placing all orders.

Steps to Reproduce the Problem

1.Setup in market BTS USD
2. 0.5% increment, 1% spread
3.

Specifications

  • Version: 0.2.0
  • OS: ubuntu 16.04

2018-05-23 10:05:02,403 - Worker 1 using account kong02 on BTS/USD - ERROR - in onMarketUpdate()
Traceback (most recent call last):
File "/home/cryptokong/.local/lib/python3.5/site-packages/dexbot-0.2.0-py3.5.egg/dexbot/worker.py", line 139, in on_market
self.workers[worker_name].onMarketUpdate(data)
File "/home/cryptokong/.local/lib/python3.5/site-packages/Events-0.3-py3.5.egg/events/events.py", line 95, in call
f(*a, **kw)
File "/home/cryptokong/.local/lib/python3.5/site-packages/dexbot-0.2.0-py3.5.egg/dexbot/strategies/staggered_orders.py", line 147, in check_orders
self.place_reverse_order(order)
File "/home/cryptokong/.local/lib/python3.5/site-packages/dexbot-0.2.0-py3.5.egg/dexbot/strategies/staggered_orders.py", line 105, in place_reverse_order
if order['base']['symbol'] == self.market['base']['symbol']: # Buy order
TypeError: 'NoneType' object is not subscriptable
2018-05-23 10:05:17,479 - Worker 1 using account kong02 on BTS/USD - INFO - Canceling all orders
2018-05-23 10:05:33,360 - Worker 1 using account kong02 on BTS/USD - INFO - Worker "Worker 1" is disabled
2018-05-23 10:05:33,362 - Worker 1 using account kong02 on BTS/USD - INFO - Worker "Worker 1" is disabled
2018-05-23 10:05:33,363 - Worker 1 using account kong02 on BTS/USD - INFO - Worker "Worker 1" is disabled

@ihaywood3 ihaywood3 mentioned this issue May 24, 2018
@MarkoPaasila MarkoPaasila changed the title Staggered orders market update error TypeError: 'NoneType' object is not subscriptable May 24, 2018
@ihaywood3
Copy link

ihaywood3 commented May 25, 2018

I have reproduced this bug
order is {'quote': None, 'base': None, 'seller': None, 'id': '1.7.75721575', 'deleted': True, 'price': None}
Problem is orders filled as soon as they are entered so dexbot never gets to see the Order as a valid object, it's only ever in the deleted state.
No easy fix I can see. One option is to record orders not as Order objects from python-bitshares, but as data structures we create fully from our data: that way we know they will be valid whatever happens when they are entered.
say as the 3-tuple (mode, price, amount) where mode is a string, "BUY" or "SELL"

@MarkoPaasila
Copy link
Collaborator

If the order is filled, it must have been included in a block and had its own ID. Is it just python-bitshares that doesn't return the ID? In the future we want to include such orders also in our statistics. Just thinking aloud...

@ihaywood3
Copy link

ihaywood3 commented May 25, 2018 via email

@mikakoi
Copy link
Collaborator

mikakoi commented May 25, 2018

Yeah the Bitshares API returns an empty result when asking for an id that doesn't exist anymore.

And as you said one option is to calculate the data on our own, but instead of changing it into a 3-tuple (which would require code rewriting all over the place) we can use the existing structure of the Order object.

All the data we really need to fill in the object is the data that we use, which are order['quote']['amount'], order['quote']['symbol'], order['base']['amount'], order['base']['symbol'], and order['price']

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants