Author [EN] [ZH] [ES] [PT] [IT] [DE] [FR] [NL] [TR] [SR] [AR] [RU] [EN] [ZH] [ES] [PT] [IT] [DE] [FR] [NL] [TR] [SR] [AR] [RU] [EN] [ZH] [ES] [PT] [IT] [DE] [FR] [NL] [TR] [SR] [AR] [RU] Topic: Trading Bot for BTSX  (Read 1140 times)

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 11964
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BTS: xeroc
  • GitHub: xeroc
Trading Bot for BTSX
« on: October 18, 2014, 12:07:12 PM »

I just now pushed a new bot I wrote ...

https://github.com/xeroc/btsx_bots

In particular the trading strategy/bot:
https://github.com/xeroc/btsx_bots/blob/master/bots/market_balance.py

For those that have been familiar with goxtool
(http://prof7bit.github.io/goxtool/) [scary reference to some long forgotten
centralized service] -- that bot should basically do the same as the 'portfolio rebalancing'
strategy of goxtool. (https://bitcointalk.org/index.php?topic=181584.0)
I haven't compared the code though!

Related theory: http://en.wikipedia.org/wiki/Rebalancing_investments#Rebalancing_bonus

It's "supposed" to keep the wealth split evenly among two assets and trades
when the market moves into either direction ..

Code: [Select]
{
"bot_type": "market_balance",           // bot name (fixed)
"account_name": "balance.bot.account",  // your account name (should be used ONLY by this bot)
"spread_percent": 0.05,                 // trades on prices moves +-5%
"asset_pair": [   
"USD", "BTSX"                   // trades in USD/BTSX in this case (first is quote, second is base)
],
"min_base_balance": 10,                 // minimum BTSX to keep
"min_quote_balance": 10                 // minimum USD to keep
},

Example output for the balancing bot:
Code: [Select]
~/btsx_bots$ python3 main.py config.json
INFO:MarketMakerBot:1 open orders -> Market has moved and order was executed! Canceling the other!
INFO:MarketMakerBot:freeing up 0.00000000  BTSX
INFO:MarketMakerBot:freeing up 66.84839000   USD
INFO:MarketMakerBot:available:   2877.65776000  BTSX            and              65.13140000   USD
INFO:MarketMakerBot:buy:           67.83787128  BTSX for price      0.02526589 -- pay      1.71398421   USD
INFO:MarketMakerBot:sell:          68.51566095  BTSX for price      0.02792546 -- get      1.91333119   USD
INFO:MarketMakerBot:submitting orders!

Remarks:
  • No external price fetching required! (running this bot only makes sense on matured markets)
  • The code is supposed to work on any asset pair as long as the market is open and the base asset has a lower id on the blockchain
  • The bot requires an initial equal distribution and if this is not the case in your account would order @ market prices  (asks for manual confirmation of orders for the initial trades) -- remark: be carefull here as the market price is taken from the btsx exchange, not from an external exchange/price feed
  • The bot places orders at +-SPREAD and allocates an amount such that after the (complete) trade has been filled, both assets hold the "same" wealth.

Todo
  • Take external price for initial balancing and wait for order to be filled
  • Set a minimum trade size
  • Incorporate trading feeds

DISCLAIMER:
- I used this to learn how to write a bot in python
- don't use with serious money unless you know what you are doing and checked the code
- I currently run one bot for USD/BTSX and CNY/BTSX with low volume to check trades, seems to work so far


THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.


Thought, critiques appreciated ..
« Last Edit: October 18, 2014, 12:41:20 PM by xeroc »
Give BitShares a try! Use the http://testnet.bitshares.eu provided by http://bitshares.eu powered by ChainSquad GmbH

Offline cube

  • Hero Member
  • *****
  • Posts: 1404
  • Bit by bit, we will get there!
    • View Profile
  • BTS: bitcube
  • Witness: bitcube
Re: Trading Bot for BTSX
« Reply #1 on: October 18, 2014, 06:42:06 PM »
Wonderful piece of work!  +5%

Will look through and learn how a bot works.
ID: bitcube
bitcube is a dedicated witness and committe member. Please vote for bitcube.

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 11964
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BTS: xeroc
  • GitHub: xeroc
Re: Trading Bot for BTSX
« Reply #2 on: October 19, 2014, 01:52:39 PM »
The initial buy oders are not working well yet .. bot is asking to confirm the initial orders ... please check them before you confirm them
Give BitShares a try! Use the http://testnet.bitshares.eu provided by http://bitshares.eu powered by ChainSquad GmbH

Offline cass

  • Hero Member
  • *****
  • Posts: 4320
  • /(┬.┬)\
    • View Profile
Re: Trading Bot for BTSX
« Reply #3 on: October 19, 2014, 08:18:30 PM »
Great work xeroc  +5%
█║▌║║█  - - -  The quieter you become, the more you are able to hear  - - -  █║▌║║█

Offline iHashFury

Re: Trading Bot for BTSX
« Reply #4 on: January 25, 2015, 05:17:30 PM »
Hello

Trying to test out your bot and run it to compliment toasts market maker bot but I'm getting the following error:

Code: [Select]
  File "main.py", line 17, in <module>
    config = read_config(sys.argv[1])
  File "/home/jason/tmp/git/btsx_bots/config.py", line 38, in read_config
    return json.load(f)
  File "/usr/lib/python3.4/json/__init__.py", line 268, in load
    parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
  File "/usr/lib/python3.4/json/__init__.py", line 318, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.4/json/decoder.py", line 343, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.4/json/decoder.py", line 359, in raw_decode
    obj, end = self.scan_once(s, idx)
ValueError: Expecting ',' delimiter: line 12 column 13 (char 313)

What am I doing wrong?

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 11964
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BTS: xeroc
  • GitHub: xeroc
Re: Trading Bot for BTSX
« Reply #5 on: January 25, 2015, 06:07:49 PM »
Code: [Select]
ValueError: Expecting ',' delimiter: line 12 column 13 (char 313)

What am I doing wrong?
I'd say you have a missing "," at the end of some parameters in your config json file .. please check them
Give BitShares a try! Use the http://testnet.bitshares.eu provided by http://bitshares.eu powered by ChainSquad GmbH

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 11964
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BTS: xeroc
  • GitHub: xeroc
Re: Trading Bot for BTSX
« Reply #6 on: January 25, 2015, 06:09:05 PM »
BTW ... please also note that @toast has released a new version of the market_maker bot .. my bots are currently under-maintained due to lack of time :(
Give BitShares a try! Use the http://testnet.bitshares.eu provided by http://bitshares.eu powered by ChainSquad GmbH

Offline kamir.tam

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Trading Bot for BTSX
« Reply #7 on: January 25, 2015, 07:00:11 PM »
Great work, gonna try this out.
« Last Edit: March 25, 2015, 04:32:01 PM by kamir.tam »

Offline abit

Re: Trading Bot for BTSX
« Reply #8 on: January 26, 2015, 05:24:51 AM »
BTW ... please also note that @toast has released a new version of the market_maker bot .. my bots are currently under-maintained due to lack of time :(
Yes, it's https://github.com/freetradebots/bts_bots
BTS account: abit
BTS committee member: abit
BTS witness: in.abit

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 11964
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BTS: xeroc
  • GitHub: xeroc
Re: Trading Bot for BTSX
« Reply #9 on: January 26, 2015, 07:35:42 AM »
BTW ... please also note that @toast has released a new version of the market_maker bot .. my bots are currently under-maintained due to lack of time :(
Yes, it's https://github.com/freetradebots/bts_bots
That's where my fork comes from ..

The new bot actually is a bter.com trading bot written in go:
https://github.com/freetradebots/market_maker
Give BitShares a try! Use the http://testnet.bitshares.eu provided by http://bitshares.eu powered by ChainSquad GmbH

 

Google+