BitShares Forum

Main => General Discussion => Topic started by: xeroc on October 18, 2014, 12:07:12 pm

Title: Trading Bot for BTSX
Post by: xeroc 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:

Todo

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 ..
Title: Re: Trading Bot for BTSX
Post by: cube on October 18, 2014, 06:42:06 pm
Wonderful piece of work!  +5%

Will look through and learn how a bot works.
Title: Re: Trading Bot for BTSX
Post by: xeroc 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
Title: Re: Trading Bot for BTSX
Post by: cass on October 19, 2014, 08:18:30 pm
Great work xeroc  +5%
Title: Re: Trading Bot for BTSX
Post by: iHashFury 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?
Title: Re: Trading Bot for BTSX
Post by: xeroc 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
Title: Re: Trading Bot for BTSX
Post by: xeroc 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 :(
Title: Re: Trading Bot for BTSX
Post by: kamir.tam on January 25, 2015, 07:00:11 pm
Great work, gonna try this out.
Title: Re: Trading Bot for BTSX
Post by: abit 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
Title: Re: Trading Bot for BTSX
Post by: xeroc 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