Author Topic: BitUSD Market Maker Live  (Read 18168 times)

0 Members and 1 Guest are viewing this topic.

Offline Riverhead

Got it working. I had to download the files directly from your link individually. I was doing git clone from the "code" tab which I thought would be the same but clearly is not :) .

Offline Riverhead


Are you on the develop branch of bitshares_toolkit?

update: Probably something with the client config. The error is it thinks "item" is an integer and not an array. Since it just got assigned on the previous line my guess is asset_array is empty.
« Last Edit: September 12, 2014, 04:49:34 pm by Riverhead »

Offline bytemaster

Getting below. Ideas?

Code: [Select]
Init price:  0.038557
Init price:  25.935917
{u'id': 0, u'result': [[u'test.riverhead', [[0, 500000000], [22, 2000000]]]]}
Traceback (most recent call last):
  File "main.py", line 107, in <module>
    init_usd_balance = client.get_balance("USD")
  File "/home/james/github/bitshares_toolkit/programs/market_maker/btsx.py", line 62, in get_balance
    if item[0] == asset:
TypeError: 'int' object has no attribute '__getitem__'

Are you on the develop branch of bitshares_toolkit?
For the latest updates checkout my blog: http://bytemaster.bitshares.org
Anything said on these forums does not constitute an intent to create a legal obligation or contract between myself and anyone else.   These are merely my opinions and I reserve the right to change them at any time.

Offline Riverhead

Getting below. Ideas?

Code: [Select]
Init price:  0.038557
Init price:  25.935917
{u'id': 0, u'result': [[u'test.riverhead', [[0, 500000000], [22, 2000000]]]]}
Traceback (most recent call last):
  File "main.py", line 107, in <module>
    init_usd_balance = client.get_balance("USD")
  File "/home/james/github/bitshares_toolkit/programs/market_maker/btsx.py", line 62, in get_balance
    if item[0] == asset:
TypeError: 'int' object has no attribute '__getitem__'
« Last Edit: September 12, 2014, 04:01:15 pm by Riverhead »

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 12922
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BitShares: xeroc
  • GitHub: xeroc
Checkout the config.json file in your BitShares data folder (%APPDATA/Roaming -- or so)
in there you can define the user name and the password ..

you can also add --rpcuser X and --rpcpassword X as parameter when launching bitshares .. (checkout "--help")

Offline robrigo


2) I modified main.py in the market_maker script to replace the account_name with my market maker. So that specifies the account to pull funds from. What is USER / PASS corresponding to then? Perhaps a registered account in my wallet as well as the wallet password?

The rpc connection specified in the client's config.json

Doh... that makes perfect sense. Thanks for the info!

Offline Riverhead


2) I modified main.py in the market_maker script to replace the account_name with my market maker. So that specifies the account to pull funds from. What is USER / PASS corresponding to then? Perhaps a registered account in my wallet as well as the wallet password?

The rpc connection specified in the client's config.json

I created a new sub account and imported the privkey into a new wallet running on a different data-dir just to keep things isolated. Don't want a script bug selling my stash :)
« Last Edit: September 12, 2014, 03:10:31 pm by Riverhead »

Offline robrigo

I will be making it significantly easier to user today

robrigo: make an account, fund it, and replace "arbiteur" with your bot's account name

Great, looking forward to your updates. So to clarify:

1) So I should follow this additional step when making bitshares_toolkit to get the release version?

Code: [Select]
# OSX users only!
export CMAKE_PREFIX_PATH=~/Qt/5.3/

cmake -DCMAKE_BUILD_TYPE=Release .
make

2) I modified main.py in the market_maker script to replace the account_name with my market maker. So that specifies the account to pull funds from. What is USER / PASS corresponding to then? Perhaps a registered account in my wallet as well as the wallet password?

Thanks for the quick answers guys!

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 12922
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BitShares: xeroc
  • GitHub: xeroc
I will be making it significantly easier to user today
Now I am expecting a GUI for the bot :-)   8) 8)

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 12922
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BitShares: xeroc
  • GitHub: xeroc
@robrigo: you realize that the "bitshares_toolkit" is for the testnet .. do you?
When compiling for the 'real' btsx network you need to do almost the same steps on the dacsunlimited/bitshares repo at github

you need to compile the "core" from:
http://wiki.bitshares.org/index.php/BuildInstructionsBitSharesX

//edit: seems I was mistaken .. sorry

Offline toast

  • Hero Member
  • *****
  • Posts: 4001
    • View Profile
  • BitShares: nikolai
I will be making it significantly easier to user today

robrigo: make an account, fund it, and replace "arbiteur" with your bot's account name
Do not use this post as information for making any important decisions. The only agreements I ever make are informal and non-binding. Take the same precautions as when dealing with a compromised account, scammer, sockpuppet, etc.

Offline robrigo

I haven't run the CLI version yet but I assume this requires the CLI version? Just wondering I tried to get it to work but keep getting connection refused:

Code: [Select]
Initializing with URL:  http://robrigo-market-maker:************@localhost:8000/rpc
Init price:  0.039835
Init price:  25.103530
Traceback (most recent call last):
  File "main.py", line 107, in <module>
    init_usd_balance = client.get_balance("USD")
  File "/Users/rob/Documents/repos/bitshares_toolkit/programs/market_maker/btsx.py", line 57, in get_balance
    response = self.request("wallet_account_balance", [self.account_name, asset])
  File "/Users/rob/Documents/repos/bitshares_toolkit/programs/market_maker/btsx.py", line 29, in request
    response = requests.post(self.url, data=json.dumps(payload), headers=headers)
  File "/Library/Python/2.7/site-packages/requests/api.py", line 92, in post
    return request('post', url, data=data, **kwargs)
  File "/Library/Python/2.7/site-packages/requests/api.py", line 48, in request
    return session.request(method=method, url=url, **kwargs)
  File "/Library/Python/2.7/site-packages/requests/sessions.py", line 451, in request
    resp = self.send(prep, **send_kwargs)
  File "/Library/Python/2.7/site-packages/requests/sessions.py", line 557, in send
    r = adapter.send(request, **kwargs)
  File "/Library/Python/2.7/site-packages/requests/adapters.py", line 407, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', error(61, 'Connection refused'))

So I assume I would need to build / run the bitshares_toolikit? If so, is there any danger of building the client when I already have the GUI installed (i.e. will it modify my current data directory?).

Edit: just remember reading somewhere I can pass an argument to make a 2nd data directory. So that should do the trick!

Thanks! I have been meaning to dig into running a delegate but my less interesting full time job comes first.

Can we have an instruction manual for how you got it to work?

I will certainly publish anything useful I can find... hoping to look into this more tonight after I finish up some more work for my employer.

You probably have the wrong port number.... make sure the port matches the port you passed to the bitshares_client via --httpport

Thanks for the response bytemaster. I was using 8000 for the port but the problem was with the fact that I had not built bitshares_toolkit yet!

So I just built the toolkit, is there some place in the technical wiki I can see all the flags that can be passed to the run command? Currently I am trying to figure out how to make my CLI instance and GUI instance "share" the same data directory... as the master branch of bitshares_toolkit created a new data directory called "BitShares XTS-Test23" to use. If I specify the directory I am using with the 0.4.14 OS X binary I get an issue with the database version:

Code: [Select]
(lldb) run --server --data-dir=/Users/rob/Library/Application\ Support/BitShares\ X/
Process 34216 launched: './bitshares_client' (x86_64)
Loading blockchain from: /Users/rob/Library/Application Support/BitShares X/chain
Loading config from file: /Users/rob/Library/Application Support/BitShares X/config.json
------------ error --------------
30012 new_database_version: new database version

    {"database_version":136,"133":133}
    th_a  chain_database.cpp:258 open_database

    {"data_dir":"/Users/rob/Library/Application Support/BitShares X/chain"}
    th_a  chain_database.cpp:302 open_database

    {"data_dir":"/Users/rob/Library/Application Support/BitShares X/chain"}
    th_a  chain_database.cpp:1094 open

    {"data_dir":"/Users/rob/Library/Application Support/BitShares X/"}
    th_a  client.cpp:1689 open
Process 34216 exited with status = 0 (0x00000000)

I'm going to guess this could probably be fixed by changing some of the config params? Some other questions:

1) Should rpc_username / rpc_password flags match the 'arbiteur' info in the market maker script? Or an account in my wallet?

2) Is it possible to share a data directory between running the latest master branch as CLI / running the GUI or should I keep these separate?

Sorry if my questions seem simple; first time actually diving into this (although I have been wanting to for weeks)!

Offline GaltReport

File "main.py", line 5
    <!DOCTYPE html>
    ^
SyntaxError: invalid syntax



what is this?I'm using Ubuntu 14

I suspect you may have downloaded it wrong.  Looks like you have an html version.

Offline bytemaster

I haven't run the CLI version yet but I assume this requires the CLI version? Just wondering I tried to get it to work but keep getting connection refused:

Code: [Select]
Initializing with URL:  http://robrigo-market-maker:************@localhost:8000/rpc
Init price:  0.039835
Init price:  25.103530
Traceback (most recent call last):
  File "main.py", line 107, in <module>
    init_usd_balance = client.get_balance("USD")
  File "/Users/rob/Documents/repos/bitshares_toolkit/programs/market_maker/btsx.py", line 57, in get_balance
    response = self.request("wallet_account_balance", [self.account_name, asset])
  File "/Users/rob/Documents/repos/bitshares_toolkit/programs/market_maker/btsx.py", line 29, in request
    response = requests.post(self.url, data=json.dumps(payload), headers=headers)
  File "/Library/Python/2.7/site-packages/requests/api.py", line 92, in post
    return request('post', url, data=data, **kwargs)
  File "/Library/Python/2.7/site-packages/requests/api.py", line 48, in request
    return session.request(method=method, url=url, **kwargs)
  File "/Library/Python/2.7/site-packages/requests/sessions.py", line 451, in request
    resp = self.send(prep, **send_kwargs)
  File "/Library/Python/2.7/site-packages/requests/sessions.py", line 557, in send
    r = adapter.send(request, **kwargs)
  File "/Library/Python/2.7/site-packages/requests/adapters.py", line 407, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', error(61, 'Connection refused'))

So I assume I would need to build / run the bitshares_toolikit? If so, is there any danger of building the client when I already have the GUI installed (i.e. will it modify my current data directory?).

Edit: just remember reading somewhere I can pass an argument to make a 2nd data directory. So that should do the trick!

Thanks! I have been meaning to dig into running a delegate but my less interesting full time job comes first.

Can we have an instruction manual for how you got it to work?

I will certainly publish anything useful I can find... hoping to look into this more tonight after I finish up some more work for my employer.

You probably have the wrong port number.... make sure the port matches the port you passed to the bitshares_client via --httpport   
For the latest updates checkout my blog: http://bytemaster.bitshares.org
Anything said on these forums does not constitute an intent to create a legal obligation or contract between myself and anyone else.   These are merely my opinions and I reserve the right to change them at any time.

Offline tonyk

  • Hero Member
  • *****
  • Posts: 3308
    • View Profile
We have produced a python script that can be used by anyone who wants to help make the BitUSD market and are looking for developers to help make it better!

https://github.com/BitShares/bitshares_toolkit/tree/develop/programs/market_maker

It is a tad crude right now, but we have plans to make this kind of script configurable for anyone who wants to perform this function. 

The rules are simple:
1) Buy BitUSD cheap (a few percent discount)
2) Sell BitUSD at the median price feed (or the latest feed from BTER) which ever is higher (in dollars per BTSX)
3) Adjust orders anytime they deviate from what the new orders would be by more than some tolerance.

Under this plan no *NEW* bitUSD will be created until the peg is hit *AND* everyone buying BitUSD can expect liquidity within just a few percent.   Meanwhile profits can be made every time someone switches sides of the market.

We are providing the script for others so that we can increase liquidity and decrease the spread (as our bots compete against each other ;) )

Users can now purchase BitUSD with confidence that they can sell it when they need to.   

Usage:
Code: [Select]
python main.py USER PASS PORT REAL_NETWORK
Example:
Code: [Select]
  python main.py user pass 8000 true
You can tweak the parameters by editing:
  main.py

Code: [Select]
SPREAD_PERCENT = 0.05  # 5%
TOLERANCE = 0.01 # should be less than SPREAD_PERCENT / 2, the closer the tolerance the more often orders are canceled/updated

MIN_USD_BALANCE = 10  #make sure you retain enough USD to pay fees to update your orders
MIN_BTSX_BALANCE = 100  # make sure you retain enough BTSX to pay fees to update your orders
MIN_USD_ORDER_SIZE = 2  # prevent dust orders
MIN_BTSX_ORDER_SIZE = 100  # minimum order size to prevent dust

MEDIAN_EDGE_MULTIPLE = 1.001 # how far in front of the median price feed do you want to sell.

Excellent. I think I will use this.

Do you have a list of features which need to be developed to extend this? What sort of improvements are possible?

I think I will try to run several artificial intelligence algos with it. The bad thing is I have never been in touch with  python . It should be rather easy to call is from C++ or Java ,right?
I have  not written a single line of code for more than 7 years also...

[EDIT] reading your own posts is a bitch... This bot already has trading logic in it, I will have to disable or change it for my needs...Stupid me...
« Last Edit: September 12, 2014, 04:32:45 pm by tonyk »
Lack of arbitrage is the problem, isn't it. And this 'should' solves it.