Bitcoin Forum
April 17, 2014, 07:47:54 AM *
News: ♦♦ A bug in OpenSSL, used by Bitcoin-Qt/Bitcoin Core, could allow your bitcoins to be stolen. Immediately updating Bitcoin Core to 0.9.1 is required in some cases, especially if you're using 0.9.0. Download. More info.
The same bug also affected the forum. Changing your forum password is recommended.
 
   Home   Help Search Donate Login Register  
Pages: [1] 2  All
  Print  
Author Topic: Trading bot?  (Read 8607 times)
bitcoinex
Sr. Member
****
Offline Offline

Activity: 350


probiwon.com


View Profile WWW

Ignore
March 06, 2011, 03:28:33 AM
 #1

Has anyone seen trading robot to trade on mtgox?

New bitcoin lottery: probiwon.com
- Может, ты ещё и в Невидимую Руку Рынка веруешь? - Зачем же веровать в то, что можно наблюдать непосредственно?
1397720874
Hero Member
*
Offline Offline

Posts: 1397720874

View Profile Personal Message (Offline)

Ignore
1397720874
Reply with quote  #2

1397720874
Report to moderator
1397720874
Hero Member
*
Offline Offline

Posts: 1397720874

View Profile Personal Message (Offline)

Ignore
1397720874
Reply with quote  #2

1397720874
Report to moderator
    mBitCASINOWIN BITCOINS IN OUR
24/7 LIVE DEALER CASINO

Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1397720874
Hero Member
*
Offline Offline

Posts: 1397720874

View Profile Personal Message (Offline)

Ignore
1397720874
Reply with quote  #2

1397720874
Report to moderator
1397720874
Hero Member
*
Offline Offline

Posts: 1397720874

View Profile Personal Message (Offline)

Ignore
1397720874
Reply with quote  #2

1397720874
Report to moderator
1397720874
Hero Member
*
Offline Offline

Posts: 1397720874

View Profile Personal Message (Offline)

Ignore
1397720874
Reply with quote  #2

1397720874
Report to moderator
riX
Sr. Member
****
Offline Offline

Activity: 326



View Profile

Ignore
March 06, 2011, 04:18:19 AM
 #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.

bitcoinex
Sr. Member
****
Offline Offline

Activity: 350


probiwon.com


View Profile WWW

Ignore
March 06, 2011, 04:59:44 AM
 #3

 I would ask that the bot began to trade on our exchange too

New bitcoin lottery: probiwon.com
- Может, ты ещё и в Невидимую Руку Рынка веруешь? - Зачем же веровать в то, что можно наблюдать непосредственно?
sidd
Newbie
*
Offline Offline

Activity: 13


View Profile

Ignore
March 07, 2011, 02:43:27 PM
 #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"}]
Clark
Hero Member
*****
Offline Offline

Activity: 540


Lead Developer - ZeroBlock


View Profile WWW

Ignore
March 07, 2011, 10:35:46 PM
 #5

I'm trying to interface with the API as well, and I am having the same issue.

ZeroBlock: The Bitcoin Trading Platform.
PGP KEY | 1Bitcoin3Tg2KWyAq3wzivdqwYqGwKYaGd
bitcoinex
Sr. Member
****
Offline Offline

Activity: 350


probiwon.com


View Profile WWW

Ignore
March 12, 2011, 11:58:11 PM
 #6

Sorry for the delay, did not notice the messages. We explore this issue.

New bitcoin lottery: probiwon.com
- Может, ты ещё и в Невидимую Руку Рынка веруешь? - Зачем же веровать в то, что можно наблюдать непосредственно?
BrightAnarchist
Donator
Hero Member
*
Offline Offline

Activity: 842



View Profile

Ignore
March 13, 2011, 01:24:20 AM
 #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"}]

romanoza
Newbie
*
Offline Offline

Activity: 15



View Profile

Ignore
March 13, 2011, 08:47:13 AM
 #8

seems to be ok now
hiker
Newbie
*
Offline Offline

Activity: 9


View Profile

Ignore
March 13, 2011, 07:34:42 PM
 #9

Are there any working bots examples, like source code etc.?
johnieeliang
Newbie
*
Offline Offline

Activity: 14


View Profile

Ignore
March 14, 2011, 01:18:43 PM
 #10

not much to making a bot, just look at the api on mtgox is all there
sidd
Newbie
*
Offline Offline

Activity: 13


View Profile

Ignore
March 14, 2011, 09: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' : <username> ,
                'pass' : <password> }

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"
johnieeliang
Newbie
*
Offline Offline

Activity: 14


View Profile

Ignore
March 15, 2011, 03:56:08 PM
 #12

why do ppl use python so often for this stuff? what are the advantages?
cw
Jr. Member
*
Offline Offline

Activity: 41


View Profile

Ignore
March 15, 2011, 04:46:47 PM
 #13

I'm developing a Python trading bot. See this post for more info.

llama
Member
**
Offline Offline

Activity: 103


View Profile

Ignore
March 16, 2011, 09: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

bitcoinex
Sr. Member
****
Offline Offline

Activity: 350


probiwon.com


View Profile WWW

Ignore
March 16, 2011, 10:09:06 PM
 #15

Our trading API is ok now?

New bitcoin lottery: probiwon.com
- Может, ты ещё и в Невидимую Руку Рынка веруешь? - Зачем же веровать в то, что можно наблюдать непосредственно?
ArsenShnurkov
Hero Member
*****
Offline Offline

Activity: 1176



View Profile WWW

Ignore
March 18, 2011, 07: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.)
bitcoinex
Sr. Member
****
Offline Offline

Activity: 350


probiwon.com


View Profile WWW

Ignore
March 18, 2011, 11: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)

New bitcoin lottery: probiwon.com
- Может, ты ещё и в Невидимую Руку Рынка веруешь? - Зачем же веровать в то, что можно наблюдать непосредственно?
ArsenShnurkov
Hero Member
*****
Offline Offline

Activity: 1176



View Profile WWW

Ignore
March 19, 2011, 09: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
Атрибут Ttl отсутствует в списке.
Продано
Атрибут Продано должен быть числом."

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
nextnonce
Member
**
Offline Offline

Activity: 74


www.minethings.com


View Profile WWW

Ignore
March 20, 2011, 09: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.

BTC accepted at my browser-based MMO, Minethings.com.  ~1500 active players mining now.
bitcoinex
Sr. Member
****
Offline Offline

Activity: 350


probiwon.com


View Profile WWW

Ignore
March 23, 2011, 03:33:10 PM
 #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
Атрибут Ttl отсутствует в списке.
Продано
Атрибут Продано должен быть числом."

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

New bitcoin lottery: probiwon.com
- Может, ты ещё и в Невидимую Руку Рынка веруешь? - Зачем же веровать в то, что можно наблюдать непосредственно?
Pages: [1] 2  All
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!