Market maker bot

Hi all,

We’ve made an open-source market-maker bot for developers and algorithmic traders to test the Nash Python API. Get it here: https://gitlab.com/nash-io-public/nash-makerbot

The makerbot is a cryptocurrency market-maker bot that is easy to understand and customize. Its goal is to create a useful practical tool to begin trading digital assets algorithmically. The bot provides a skeleton to build upon for traders wanting to perform market-maker strategies. Its default configuration should allow for trading on Nash out of the box, so users can start quickly.

16 Likes

Hello Fabio,
This is the most wanted feature for the community, we really thank you allowing us have something like this in the exchange.
I was testing it since yesterday on almost all Linux distribution, it worked for them all with some issues, but with Debian 10, it was very stable, i did the installation twice, the same result.
Here are some of remarks:
When the bot is running and placing orders, after some time it will reach the max allowed amount for all assets, and then will stop automatically, but the orders remain there, so when you run it again, these orders are not anymore in his strategy.

second remark:
Is about the 2FA, only when you disable 2FA on your account the bot work perfectly, if you don’t, even with deactivating the Auto-re-login, after sometime it just block, will not place orders, maybe some cache issue.

Third remark:
It happened only after reaching the max allowed amount, i then edited the config.ini file, and extended to 250 (was 100), as you can see in the picture, even if i have more than 250 in my trading account, it keep giving me this error ( even after clearing cache / reboot ):

2019-12-08 00:13:47,811:INFO: Enter market maker loop
2019-12-08 00:14:18,651:INFO: No buy order, checking if should place scrum buy.

GraphQL query failed with 1 errors
GraphQL query failed with 1 errors
GraphQL query failed with 1 errors
GraphQL query failed with 1 errors
2019-12-08 00:14:20,123:INFO: Canceling bot buy order if any.
Traceback (most recent call last):
File “/usr/local/bin/makerbot”, line 10, in
sys.exit(main())
File “/usr/local/lib/python3.7/dist-packages/makerbot/core.py”, line 284, in main
setup_scrum_buy(market, obs, df, buy_order, max_amount)
File “/usr/local/lib/python3.7/dist-packages/makerbot/core.py”, line 171, in setup_scrum_buy
place_order(market, buy_1)
File “/usr/local/lib/python3.7/dist-packages/makerbot/core.py”, line 79, in place_order
placed = retry(lambda: api.place_limit_order(market.name,
File “/usr/local/lib/python3.7/dist-packages/makerbot/helpers.py”, line 40, in retry
raise exception
File “/usr/local/lib/python3.7/dist-packages/makerbot/helpers.py”, line 36, in retry
return func()
File “/usr/local/lib/python3.7/dist-packages/makerbot/core.py”, line 84, in
order.allow_taker))
File “/usr/local/lib/python3.7/dist-packages/nash/graphql_mutating.py”, line 249, in place_limit_order
raise error
File “/usr/local/lib/python3.7/dist-packages/nash/graphql_mutating.py”, line 238, in place_limit_order
res = self._exec_gql_query(op)
File “/usr/local/lib/python3.7/dist-packages/nash/api.py”, line 267, in _exec_gql_query
raise GraphQlError(errors)
nash.exceptions.GraphQlError: [{‘locations’: [{‘column’: 1, ‘line’: 2}], ‘message’: “validation error caused by ‘amount’ - requirement: - reason: Amount lower than min_value on targeted market - got: ~C[0.47200000 neo]”, ‘path’: [‘placeLimitOrder’]}]
root@vps764038:~#

This is a feedback, i know that this bot is not yer finished, but just to improve it and refine it. i’m still testing it, if i find out how, i will add it here.
Thanks in advance.

4 Likes

Great progress! I’m not really a trader myself, let alone an algorithmic trader. However, I do want to help with liquidity for the exchange and am willing to risk some of my portfolio. Could someone from the community help me out by creating a post for sharing default settings for:

  1. conservative (day)trading
  2. medium risk/reward
  3. high risk/reward

Hope people are willing to help out!

Kind regards,
Nick

4 Likes

Nice job team. However, I keep getting the following error:

starting ...

2019-12-08 12:03:39,879:INFO: Canceling bot buy order if any.
Traceback (most recent call last):
  File "/home/nick/.local/bin/makerbot", line 11, in <module>
    sys.exit(main())
  File "/home/nick/.local/lib/python3.7/site-packages/makerbot/core.py", line 244, in main
    api.login(login, pwd, twofa)
  File "/home/nick/.local/lib/python3.7/site-packages/nash/api.py", line 160, in login
    for chain_index in response["chain_index"]:
KeyError: 'chain_index'

Update: nevermind, I’ve dumped the response and the message was that 2FA is required. So I need to disable 2FA on my account for it to work, like @Achlem said. Hope this gets fixed soon.

2 Likes

I just pushed a new version 0.1.4 that adds an additional check and some better handling for when the exchange goes into maintenance (longer backoff on the retry).

@Achlem I added a update on the default.ini to make it clear that when you enter max_funds on a market, it is defined in the quote currency of the market. A market name is of type base_quote . So in a neo_eth market those values are defined in ETH, so 200 would be ~ $30,000.

@Nick I am disabling 2FA support from the bot for now. Will look into it.

8 Likes

Awesome :slight_smile:

1 Like

Now the config.ini is very clear, i tought ( and others) that the max funds were in usd; so it was for the current open market.
However, i have 2FA in my account, when running the bot, it’s not asking 2FA anymore, but still the chain_index waiting for a 2FA confirmation it seems.

Nash login password:
starting …

2019-12-08 17:23:00,886:INFO: Canceling bot buy order if any.
Traceback (most recent call last):
File “/usr/local/bin/makerbot”, line 10, in
sys.exit(main())
File “/usr/local/lib/python3.7/dist-packages/makerbot/core.py”, line 246, in main
api.login(login, pwd, None)
File “/usr/local/lib/python3.7/dist-packages/nash/api.py”, line 160, in login
for chain_index in response[“chain_index”]:
KeyError: ‘chain_index’

1 Like

Yeah the 2FA is only disabled for the bot setting. The API still needs it though if you have it enabled on the platform, which makes sense :slight_smile:

I’ve got the following error. Any idea on how to fix this?

OSError: /home/pi/.local/lib/python3.7/site-packages/nash/nash.linux.so: wrong ELF class: ELFCLASS64

I think you’re trying to run it on a 32-bit OS, you need 64-bit for it to work.

It’s still not working for me. I keep getting the GraphQL failures:

starting ...

Pubkey :  ----
2019-12-09 09:13:51,548:INFO: Enter market maker loop
2019-12-09 09:22:02,980:INFO: No buy order, checking if should place scrum buy.
GraphQL query failed with 1 errors
GraphQL query failed with 1 errors
GraphQL query failed with 1 errors
GraphQL query failed with 1 errors
GraphQL query failed with 1 errors
GraphQL query failed with 1 errors
GraphQL query failed with 1 errors
GraphQL query failed with 1 errors
GraphQL query failed with 1 errors
GraphQL query failed with 1 errors
GraphQL query failed with 1 errors
GraphQL query failed with 1 errors
GraphQL query failed with 1 errors
GraphQL query failed with 1 errors
GraphQL query failed with 1 errors
GraphQL query failed with 1 errors
Detected GQL error 'unauthorized'...
Trying RELOGIN...
Pubkey :  ----
GraphQL query failed with 1 errors
GraphQL query failed with 1 errors
Detected GQL error 'unauthorized'...
Trying RELOGIN...
Pubkey :  ----
GraphQL query failed with 1 errors

Trying the neo_eth market, and I have the max values in default.ini set to lower than my balances so that shouldn’t be the problem I guess?

Yeah I see it now. Was convinced the new RPi 4 ran on 64bit, but it’s not. I’ll wait for an update where 32bit gets supported

@Nick could you contact support@nash.io ? This looks like some auth issue.

1 Like

Hello Fabio

I am testing the nash-makerbot and also facing the "GraphQL query failed with 1 errors¨ issue Nick is mentions above. I found out the error occurs in the /makerbot/core.py module in the´market maker´-loop in setup_scrum_buy(…) -> place_order(…).

The error message is fire in
placed = retry(lambda: api.place_limit_order(market.name,amount,order.buy_or_sell,order.cancellation_policy,str(order.price), order.allow_taker))

The variables used in placed() are filled with following values:
2020-01-18 21:42:12,730:INFO: Enter market maker loop
2020-01-18 21:42:28,429:DEBUG: Updating orderbook series and dataframe.
2020-01-18 21:42:29,144:INFO: No buy order, checking if should place scrum buy.
2020-01-18 21:42:29,145:INFO: market.name neo_eth
2020-01-18 21:42:29,145:INFO: amount 0.400 neo
2020-01-18 21:42:29,145:INFO: order.buy_or_sell BUY
2020-01-18 21:42:29,145:INFO: order.cancellation_policy GOOD_TIL_CANCELLED
2020-01-18 21:42:29,145:INFO: str(order.price) 0.06838
2020-01-18 21:42:29,145:INFO: order.allow_taker True
GraphQL query failed with 1 errors
GraphQL query failed with 1 errors

These GraphQL can go on for hours until the script is stopped with ctrl+c for for other reasons.
I am running the script in Ubuntu19.04 64bit with Gnome teminal.
The 2FA option is disabled in my account.

Is there a way to solve my GraphQL query error also ?

Kind regards , Erwin

Hi @Erwin5423 this GraphQL issue happens when the session expires (sign out), so you could simply try to reconnect in that moment.

I will look into adding this logic with some other updates later to see make it easier.

1 Like