Author

Topic: Trading bot? (Read 12678 times)

newbie
Activity: 8
Merit: 0
June 08, 2011, 01:38:06 PM
#26
You can already do all of that with sierra charts. They have an API which you can tweak your own buy sell algorithms. The trick for me was to create a rely (i wrote mine in java) between mtgox and the trade feed in sierra charts.

as for the Trading API, all requests must be POST. You also do no specify the parameters in the query string. This is a low level secuirtyu mechanism for people sniffing urls, like your job, isp, router, etc...

Another great tool and easy to setup is to download and install the firefox plugin call Poster. This plugin lets you perform any type of HTTP request. I have multiple poster dialogs opened up for each of the actuions i commonly do. And tweak the parameters as needed. I trust this a little more (dont know why) then manually typing these at the command line.

Ive found this is a little faster then the website,since you are skipping the entire gui part.

If someone has some good ideas for a bot, maybe we can collab, right now i have to many other bitcoin projects im in the middle of working on, but i do have a little time to dedicate to a team working on a bot.

lastly if anyone has any concepts for a trading desktop app, thats another project i would like to use, cuz well, i dont really like sierra charts to much, between its lack of asthetics, and many quirks

happy trading =)
newbie
Activity: 22
Merit: 0
June 07, 2011, 08:37:56 PM
#25
All in 3d with motion capture and all, I'm in!  Grin
hero member
Activity: 548
Merit: 502
So much code.
April 02, 2011, 01:50:35 PM
#24
The reason is the same for having any API at all: you would like to provide a way for the user to perform any function of the service from an external interface.

Think of Twitter and external Twitter apps. I envision a future application for Bitcoin trading where one single desktop client will be able to present the user with their trading accounts from multiple exchanges. It would naturally need an API call to transfer money, so there could be transfers between accounts, or out of the system altogether.
hero member
Activity: 644
Merit: 503
April 02, 2011, 06:35:56 AM
#23
It would be very helpful if BTCex.com exposed an API call to send Bitcoins to any address, similar to the one on Mt. Gox. There is a form for the user to fill in under the Funds tab, but it would be very nice to do it through an external interface.

Easey to implement this but why?
I suppose then BTCex.com could be used as a payment mechanism - "click here to buy this using your bitcoins stored at BTCex.com".

I can see it being useful, but it would be good if it were opt-in only. I quite like the idea that any bitcoin withdrawal at an exchange can only go to the one bitcoin address - it adds to the security.
sr. member
Activity: 350
Merit: 252
probiwon.com
April 02, 2011, 02:15:40 AM
#22
It would be very helpful if BTCex.com exposed an API call to send Bitcoins to any address, similar to the one on Mt. Gox. There is a form for the user to fill in under the Funds tab, but it would be very nice to do it through an external interface.

Easey to implement this but why?
hero member
Activity: 548
Merit: 502
So much code.
April 02, 2011, 01:42:56 AM
#21
It would be very helpful if BTCex.com exposed an API call to send Bitcoins to any address, similar to the one on Mt. Gox. There is a form for the user to fill in under the Funds tab, but it would be very nice to do it through an external interface.
sr. member
Activity: 350
Merit: 252
probiwon.com
March 23, 2011, 10:33:10 AM
#20
We solve problems as they come (excluding security problems)

1) I am trying to give the order:
https://btcex.com/api/order?order_type=Limit&quantity_sell=1.98&pair=150&rate=4.0001&Ttl=10&ask=0&username=ArsenShnurkov&token=hereIsMyCoRRecTSesSioNid1111

It returns
{"error":"Wrong parameters"}

Given this explaination I am unable to determine what goes wrong.

2) If I write "ttl" instead of "Ttl" site returns:
"Ttl
Aтpибyт Ttl oтcyтcтвyeт в cпиcкe.
Пpoдaнo
Aтpибyт Пpoдaнo дoлжeн быть чиcлoм."

2.1) Why russian letters are returned in this answer ?
2.2) Sample at API description page says to use "&ttl=". So it is a bug either in documentation or in code.

3) It is not documented - what should one use as a value of Ttl field

4) It is not documented which separators of decimal digits are accepted

1. In docs there is ttl, but not Ttl, read it carefully.
2.1 RTFM: For all requests you can determine language of error messages with 'language' param. Possible values is 'en' or 'ru'.
2.3 It must be ttl
3. It was, but was cleared by mistake. Now it returned.
0 minutes
15 minutes
1 hour
3 hours
6 hours
12 hours
1 day
3 days
7 days
10 days
14 days

4. Added
member
Activity: 74
Merit: 11
www.minethings.com
March 20, 2011, 04:57:10 PM
#19
Here's the source to a fairly basic sellingbot for Mt Gox. I just use it to trade mined btc for $, but you could add more advanced trading logic if you wanted.
The BTCex API seems to be fixed now, the only real difference between the API's is that BTCex is all 'GET' and no 'POST'.


FYI, decimal.getcontext().prec is not the number of digits after the decimal point but rather the number of total digits in the number.  So you should leave that alone and use decimal.Decimal.quantize() instead.
legendary
Activity: 1386
Merit: 1000
March 19, 2011, 04:00:06 AM
#18
We solve problems as they come (excluding security problems)

1) I am trying to give the order:
https://btcex.com/api/order?order_type=Limit&quantity_sell=1.98&pair=150&rate=4.0001&Ttl=10&ask=0&username=ArsenShnurkov&token=hereIsMyCoRRecTSesSioNid1111

It returns
{"error":"Wrong parameters"}

Given this explaination I am unable to determine what goes wrong.

2) If I write "ttl" instead of "Ttl" site returns:
"Ttl
Aтpибyт Ttl oтcyтcтвyeт в cпиcкe.
Пpoдaнo
Aтpибyт Пpoдaнo дoлжeн быть чиcлoм."

2.1) Why russian letters are returned in this answer ?
2.2) Sample at API description page says to use "&ttl=". So it is a bug either in documentation or in code.

3) It is not documented - what should one use as a value of Ttl field

4) It is not documented which separators of decimal digits are accepted
sr. member
Activity: 350
Merit: 252
probiwon.com
March 18, 2011, 06:10:44 PM
#17
Our trading API is ok now?

No, of course! Documentation is still awfull. (I talk about https://btcex.com/site/page/api page)
And it is not localized to russian language.

(I am incubating a devious plan to build a robot for btcex.com, codenamed "Diamond Dust".
Please tremble in horror and prepare to a large number of orders in the order stack.
I think that you should either limit visible number of orders or/and add paging.
You just was forewarned.)

We solve problems as they come (excluding security problems)
legendary
Activity: 1386
Merit: 1000
March 18, 2011, 02:11:20 PM
#16
Our trading API is ok now?

No, of course! Documentation is still awfull. (I talk about https://btcex.com/site/page/api page)
And it is not localized to russian language.

(I am incubating a devious plan to build a robot for btcex.com, codenamed "Diamond Dust".
Please tremble in horror and prepare to a large number of orders in the order stack.
I think that you should either limit visible number of orders or/and add paging.
You just was forewarned.)
sr. member
Activity: 350
Merit: 252
probiwon.com
March 16, 2011, 05:09:06 PM
#15
Our trading API is ok now?
member
Activity: 103
Merit: 61
March 16, 2011, 04:11:53 PM
#14
The bot on MtGox is mine. It runs nearly all the time, but it's not always making trades. I brought it online the day Jed opened up the API.

Mt. Gox is the only exchange with enough volume to justify trading in right now. Sorry, source will remain closed Wink
cw
newbie
Activity: 41
Merit: 0
March 15, 2011, 11:46:47 AM
#13
I'm developing a Python trading bot. See this post for more info.
newbie
Activity: 14
Merit: 0
March 15, 2011, 10:56:08 AM
#12
why do ppl use python so often for this stuff? what are the advantages?
newbie
Activity: 13
Merit: 0
March 14, 2011, 04:14:52 PM
#11
Here's the source to a fairly basic sellingbot for Mt Gox. I just use it to trade mined btc for $, but you could add more advanced trading logic if you wanted.
The BTCex API seems to be fixed now, the only real difference between the API's is that BTCex is all 'GET' and no 'POST'.
Code:
#!/usr/bin/python

# Basic Mt Gox salesbot
# Will automatically sell all BTC for USD
# CAUTION - USE AT YOUR OWN RISK
# AUTOMATIC TRADING MAY RESULT IN FINANCIAL LOSS

from urllib import urlencode
import httplib2
import json
from decimal import *

#### User Variables ####
TRADING_FOR_REAL = False

CREDENTIALS = { 'name' : ,
                'pass' : }

SPREAD_LIMIT = Decimal('0.010') # Critical difference between best bid and best offer.
                               # If the spread is less than this, take the best bid.
                               # If the spread is larger than this, undercut the best offer.
                               # set to 0 for a patient algorithm.
                               # set to a large number for an impatient algorithm.
                               # There is no check that the best bid has sufficient volume.

UNDERCUT_AMOUNT = Decimal('0.0050') # If making a patient trade, undercut best offer by this much.

SMALLEST_TRADE = 10 # Minimum value of trade in btc that Mt Gox allows.

DECIMAL_PRECISION = 4 # Decimal places for price data

#### Mt Gox urls ####
Ticker = 'http://mtgox.com/code/data/ticker.php'
Depth = 'http://mtgox.com/code/data/getDepth.php'
Funds = 'https://mtgox.com/code/getFunds.php?'
Buybtc = 'https://mtgox.com/code/buyBTC.php?'
Sellbtc = 'https://mtgox.com/code/sellBTC.php?'
Myorders = 'https://mtgox.com/code/getOrders.php?'
Cancelorder = 'https://mtgox.com/code/cancelOrder.php?'

#### Trading Functions ####
h = httplib2.Http('.cache')
getcontext().prec = DECIMAL_PRECISION

def GetTicker():
    response, content = h.request(Ticker)
    return content

def CancelAll():
    # Cancel every outstanding order
    # Return account balance (BTC, $)
    response, content = h.request(Myorders,
                                  'POST',
                                  urlencode(CREDENTIALS),
                                  headers={'Content-Type': 'application/x-www-form-urlencoded'})
    a = json.loads(content)
    print "There are ", len(a[u'orders']), " existing orders to cancel"

    mybody = dict(CREDENTIALS)
    if TRADING_FOR_REAL:
        for order in a[u'orders']:
            mybody['oid'] = order[u'oid']
            mybody['type'] = order[u'type']
            response, content = h.request(Cancelorder,
                                          'POST',
                                          urlencode(mybody),
                                          headers={'Content-Type': 'application/x-www-form-urlencoded'})
        print "All orders cancelled"
    else:
        print "Orders have not been cancelled"
       
    return (a[u'btcs'], a[u'usds'])

def PlaceSell(price, amount):
    mybody = dict(CREDENTIALS)
    mybody['price'] = price
    mybody['amount'] = amount
    if (TRADING_FOR_REAL):
        print "Selling ", amount, " btc at ", price
        response, content = h.request(Sellbtc,
                                      'POST',
                                      urlencode(mybody),
            headers={'Content-Type': 'application/x-www-form-urlencoded'})
    else:
        print "Trading disabled but would sell ", amount, " btc at ", price
       
#### Trading strategy ####
# First cancel all open orders
# Then attempt to sell all BTC in account
#
# Trade patiently if the spread is large
# Trade impatiently if the spread is small

# must deal in quantities > 10 btc

mybtc, myusd = CancelAll()

a = json.loads(GetTicker())
bestsell = Decimal(str(a[u'ticker'][u'sell']))
bestbuy = Decimal(str(a[u'ticker'][u'buy']))
last = Decimal(str(a[u'ticker'][u'last']))

print "Bid: ", bestbuy, ", Offer: ", bestsell

# Place an order to sell BTC
if bestsell > bestbuy + SPREAD_LIMIT:
    # Wide spread
    sellprice = bestsell - UNDERCUT_AMOUNT
    sellamount = mybtc # full balance of account
    if sellamount > SMALLEST_TRADE:
        PlaceSell( sellprice, sellamount)
    else:
        print "Insufficient btc in account to make patient sale"
else:
    # Tight spread
    sellprice = bestbuy
    sellamount = mybtc # full balance of account
    if sellamount > SMALLEST_TRADE:
        PlaceSell( sellprice, sellamount)
    else:
        print "Insufficient btc in account to match existing bid"
newbie
Activity: 14
Merit: 0
March 14, 2011, 08:18:43 AM
#10
not much to making a bot, just look at the api on mtgox is all there
newbie
Activity: 58
Merit: 0
March 13, 2011, 02:34:42 PM
#9
Are there any working bots examples, like source code etc.?
newbie
Activity: 15
Merit: 0
March 13, 2011, 03:47:13 AM
#8
seems to be ok now
donator
Activity: 853
Merit: 1000
March 12, 2011, 08:24:20 PM
#7
I tried httplib2 many times to no avail, generally I find that the mechanize package works far better. although it cannot execute javascript for you.

I've made a simple bot on mtgox that works.

I've tried to make a bot for your site, but can't get it to work. If I try the simple program:
Code:
import httplib2
h = httplib2.Http('.cache')
url = "https://btcex.com/api/orders?username=sidd&token=****"
r,c = h.request(url)
print c

It always returns an empty list []

If I use the exact same url in a browser while logged out of btcex it also returns []
If I use the same url in a browser while logged in it lists orders correctly, eg: [{"pair_id":2,"order_id":59670,"order_type":"Limit","ask":true,"rate":"10.0000","rate_reverse":"0.1000","quantity_sell":"1.00","ttl":"14 days"}]

sr. member
Activity: 350
Merit: 252
probiwon.com
March 12, 2011, 06:58:11 PM
#6
Sorry for the delay, did not notice the messages. We explore this issue.
hero member
Activity: 548
Merit: 502
So much code.
March 07, 2011, 05:35:46 PM
#5
I'm trying to interface with the API as well, and I am having the same issue.
newbie
Activity: 13
Merit: 0
March 07, 2011, 09:43:27 AM
#4
I've made a simple bot on mtgox that works.

I've tried to make a bot for your site, but can't get it to work. If I try the simple program:
Code:
import httplib2
h = httplib2.Http('.cache')
url = "https://btcex.com/api/orders?username=sidd&token=****"
r,c = h.request(url)
print c

It always returns an empty list []

If I use the exact same url in a browser while logged out of btcex it also returns []
If I use the same url in a browser while logged in it lists orders correctly, eg: [{"pair_id":2,"order_id":59670,"order_type":"Limit","ask":true,"rate":"10.0000","rate_reverse":"0.1000","quantity_sell":"1.00","ttl":"14 days"}]
sr. member
Activity: 350
Merit: 252
probiwon.com
March 05, 2011, 11:59:44 PM
#3
 I would ask that the bot began to trade on our exchange too
riX
sr. member
Activity: 326
Merit: 254
March 05, 2011, 11:18:19 PM
#2
Today there was a bot online there.
The bot kept adjusting it's order so to always be included in the lowest 500 USD worth of sell orders.
It's easy to see if it's online.
sr. member
Activity: 350
Merit: 252
probiwon.com
March 05, 2011, 10:28:33 PM
#1
Has anyone seen trading robot to trade on mtgox?
Jump to: