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

0 Members and 1 Guest are viewing this topic.

Offline Riverhead

I wrote this very crude function to make it easier for me to track the performance of the robot over time. There are already get_balance formulas for the wallet so this is for open orders converted to USD.

I use this to have a window open that just streams the following: "USD total value" "USD Wallet" "BTSX Wallet" "USD Open Orders"

Code: [Select]
2014-0914-08:02:28 413.743444392 3.8038 99.5 406.231799437
2014-0914-08:03:32 413.754224567 3.8038 99.5 406.231799437

This is my first poke at python so the code is probably pretty crude for someone more proficient. This is also hard coded to me and USD/BTSX.


Code: [Select]
    def get_my_costs(self):
        orders_total_cost = 0
        response = self.request("wallet_market_order_list", ["USD", "BTSX", -1, "spikel"])
        for pair in response.json()["result"]:
            item = pair[1]
            order_balance = float(item["state"]["balance"])
            order_ratio = float(item["market_index"]["order_price"]["ratio"])
            if (item["market_index"]["order_price"]["quote_asset_id"] == 22):
                order_amount = (order_balance * order_ratio) / 10000
            else:
                order_amount = order_balance / 10000
            orders_total_cost = (orders_total_cost + order_amount)
        return orders_total_cost

38PTSWarrior

  • Guest
Thank you so much. I was again on autopilot and was doing only cd bitsharesx, make bitshares_client without the git checkout develop. I think I will delete the new files nd do it again. Bot I'm coming =)

Offline robrigo

How do I git clone the develop branch? I am almost sure it's not this one: git clone https://github.com/dacsunlimited/bitsharesx

I tried git clone https://github.com/BitShares/bitshares_toolkit/tree/develop/programs/market_maker   but that didn't work.

You had it right initially. git clone will clone the entire git repo; then you can switch to the develop branch by doing:


git checkout develop

38PTSWarrior

  • Guest
How do I git clone the develop branch? I am almost sure it's not this one: git clone https://github.com/dacsunlimited/bitsharesx

I tried git clone https://github.com/BitShares/bitshares_toolkit/tree/develop/programs/market_maker   but that didn't work.

Offline betax

  • Hero Member
  • *****
  • Posts: 808
    • View Profile
Ive been running the latest no problem for a ~ day, only issue is that the password is before the user name (that confused me for a while doh!).
https://metaexchange.info | Bitcoin<->Altcoin exchange | Instant | Safe | Low spreads

Offline robrigo

I'm in with some little stake .. let's see how to works out ...
can we have a modified version for btiGLD and bitCNY too?

I'm gonna check through the code .. maybe I can figure it out myself :)

There are a couple simple naming inconsistencies I found in the logging from running the latest market maker for a little bit...

In btsx.py:

line 87: "account_name" (no quotes) should be replaced with "account".

I saw another but it looks like it was already fixed.  ;) Those caused my bot to terminate.

38PTSWarrior

  • Guest

Offline cass

  • Hero Member
  • *****
  • Posts: 4311
  • /(┬.┬)\
    • View Profile
I will be making it significantly easier to user today
Now I am expecting a GUI for the bot :-)   8) 8)

 +5% 8)
█║▌║║█  - - -  The quieter you become, the more you are able to hear  - - -  █║▌║║█

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 12922
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BitShares: xeroc
  • GitHub: xeroc
I'm in with some little stake .. let's see how to works out ...
can we have a modified version for btiGLD and bitCNY too?

I'm gonna check through the code .. maybe I can figure it out myself :)

Offline robrigo

The latest develop branch has a revamped market maker bot architecture. I'm designing it in a way where it should be easy for people to write and share trading bots with configurable parameters.

New usage:

python main.py path_to_bot_config.json

It will create a new config with one default bot configured.
Edit this file with rpc client info and your bot settings.
You can look at the top of config.py to read more about the parameters.

Watch this space...

Bot frameworks 4 the win. I'm running it smoothly now alongside my GUI wallet.  8) Thanks toast.

Offline emailtooaj

Sound Editor of Beyondbitcoin Hangouts. Listen to latest here - https://beyondbitcoin.org support the Hangouts! BTS Tri-Fold Brochure https://bitsharestalk.org/index.php/topic,15169.0.html
Tip BROWNIE.PTS to EMAILTOOAJ

Offline toast

  • Hero Member
  • *****
  • Posts: 4001
    • View Profile
  • BitShares: nikolai
The latest develop branch has a revamped market maker bot architecture. I'm designing it in a way where it should be easy for people to write and share trading bots with configurable parameters.

New usage:

python main.py path_to_bot_config.json

It will create a new config with one default bot configured.
Edit this file with rpc client info and your bot settings.
You can look at the top of config.py to read more about the parameters.

Watch this space...
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

Mine is running:

Code: [Select]
TYPE        QUANTITY            PRICE                         BALANCE             COST                COLLATERAL          ID                                 
================================================================================================================================
bid_order   5,005.18188 BTSX    0.03917587898743254 USD / BTSX196.0824 USD        196.0823 USD        N/A                 7a160369d1c67da0ecf6d9ca719219933f03d39e
ask_order   4,899.80000 BTSX    0.04113467293680417 USD / BTSX4,899.80000 BTSX    201.5516 USD        N/A                 7bd0600b46d2b5f0b1ad5b824335a0b5c96d4c54

Steps I took:

1) git clone the develop branch
2) Do the two submodule commands and then cmake .
3) make bitshares_client
4) ./bitshares_client --data-dir ~/.usd_market_maker
5) create_wallet <whatever>
6) import_private_key <some key from a trading account you created>
7) quit client and update the config.json with your desired user/pass. Add /rpc to the end of the https bit after the port
8 ) download the bot files from BM's link
9) edit main.py with your account name (make sure the account has at least 1001 BTSX and 100 USD (I went 4000/200)
10) python main.py user pass port true

Nice! Putting it in a separate data-dir is definitely a better idea; right now I am seeing problems after exiting the CLI wallet and trying to open the GUI where it isn't connecting me in the GUI. I clicked "Enable Transaction Scanning" but it is just kind of hung there atm. I changed the config.json parameters back to what they originally were but keeping a separate data-dir for this would probably prevent the issue I am seeing.

I will probably rename everything in the data-dir except for the wallet and see if that fixes my issue.

Offline Riverhead

Mine is running:

Code: [Select]
TYPE        QUANTITY            PRICE                         BALANCE             COST                COLLATERAL          ID                                 
================================================================================================================================
bid_order   5,005.18188 BTSX    0.03917587898743254 USD / BTSX196.0824 USD        196.0823 USD        N/A                 7a160369d1c67da0ecf6d9ca719219933f03d39e
ask_order   4,899.80000 BTSX    0.04113467293680417 USD / BTSX4,899.80000 BTSX    201.5516 USD        N/A                 7bd0600b46d2b5f0b1ad5b824335a0b5c96d4c54

Steps I took:

1) git clone the develop branch
2) Do the two submodule commands and then cmake .
3) make bitshares_client
4) ./bitshares_client --data-dir ~/.usd_market_maker
5) create_wallet <whatever>
6) import_private_key <some key from a trading account you created>
7) quit client and update the config.json with your desired user/pass. Add /rpc to the end of the https bit after the port
8 ) download the bot files from BM's link
9) edit main.py with your account name (make sure the account has at least 1001 BTSX and 100 USD (I went 4000/200)
10) python main.py user pass port true

Offline robrigo

I think I have it working now... here are the steps I took:

1) Build bitsharesx repo by following these instructions: http://wiki.bitshares.org/index.php/BuildInstructionsBitSharesX

Except for the "Configuration and Compilation (Core)" step; here i had to change the CMAKE_PREFIX_PATH part of the command:

Code: [Select]
# OSX users only!
export CMAKE_PREFIX_PATH=/usr/local/ssl

cmake -DCMAKE_BUILD_TYPE=Release .
make

2) Copy market_maker program from develop branch of bitshares_toolkit repo over to "programs" in bitsharesx repo. You have to edit "main.py" and replace "local-market-maker" with your local account.

3) Edit config.json in data directory to specify an rpc_user / rpc_password, and set "enable" to true.

4) Run bitshares_client in bitsharesx repo as mentioned here:

https://github.com/BitShares/bitshares_toolkit/wiki/DPOS-initial-delegate-setup

For this step I passed the following flags to run: --rpcuser=user --rpcpassword=***** --server

5) Now, I opened my wallet on the CLI by running

Code: [Select]
wallet_open <NAME>

5) Then I could go into "market_maker" and run it as described in bytemasters original post:

python main.py <RPC_USER> <RPC_PASSWORD> <HTTP_RPC_PORT> <LIVE?>

After I got output like:

Code: [Select]
Initializing with URL:  http://<USER>:<PASSWORD>@localhost:<PORT>/rpc
Init price:  0.038721
Init price:  25.825624
{u'id': 0, u'result': [[u'<LOCAL_ACCOUNT>', [[0, 10000000000]]]]}
[u'<LOCAL_ACCOUNT>', [[0, 10000000000]]]
[[0, 10000000000]]
[0, 10000000000]
0.0
{u'id': 0, u'result': [[u'<LOCAL_ACCOUNT>', [[0, 10000000000]]]]}
[u'<LOCAL_ACCOUNT>', [[0, 10000000000]]]
[[0, 10000000000]]
[0, 10000000000]
100000.0
0.0
Price moved  -  old:  0.038721   new:  0.038721

   u'id':0,
   u'result':{ 
      u'blockchain_head_block_timestamp':u'20140912T170240',
      u'blockchain_average_delegate_participation':85.59322033898304,
      u'wallet_unlocked':False,
      u'wallet_next_block_production_time':None,
      u'blockchain_share_supply':199988581761744,
      u'network_num_connections':0,
      u'blockchain_delegate_pay_rate':155505,
      u'blockchain_next_round_timestamp':u'20140912T171950',
      u'ntp_time_error':-4.27297,
      u'blockchain_random_seed':u'ff8666c7c8c734f737d1005e5862b050aaf0f62a',
      u'blockchain_next_round_time':854,
      u'wallet_block_production_enabled':None,
      u'network_num_connections_max':200,
      u'wallet_last_scanned_block_timestamp':None,
      u'wallet_next_block_production_timestamp':None,
      u'wallet_unlocked_until_timestamp':None,
      u'wallet_open':True,
      u'blockchain_accumulated_fees':18809928977,
      u'blockchain_head_block_num':467948,
      u'blockchain_confirmation_requirement':1,
      u'client_data_dir':u'/Users/rob/Library/Application Support/BitShares X',
      u'blockchain_head_block_age':176,
      u'blockchain_blocks_left_in_round':86,
      u'wallet_unlocked_until':None,
      u'ntp_time':u'20140912T170536',
      u'wallet_scan_progress':None,
      u'client_version':u'0.4.14'
   }
}

I haven't seen any additional output at all yet; haven't read the python completely either to see if that is expected. Maybe I also need to run a command to "unlock" my wallet first?