Bitcoin Forum
April 20, 2024, 04:16:12 AM *
News: Latest Bitcoin Core release: 26.0 [Torrent]
 
   Home   Help Search Login Register More  
Warning: One or more bitcointalk.org users have reported that they strongly believe that the creator of this topic is a scammer. (Login to see the detailed trust ratings.) While the bitcointalk.org administration does not verify such claims, you should proceed with extreme caution.
Pages: [1] 2 »  All
  Print  
Author Topic: Trading bot?  (Read 12675 times)
bitcoinex (OP)
Sr. Member
****
Offline Offline

Activity: 350
Merit: 252


probiwon.com


View Profile WWW
March 06, 2011, 03:28:33 AM
 #1

Has anyone seen trading robot to trade on mtgox?

New bitcoin lottery: probiwon.com
- Moжeт, ты eщё и в Heвидимyю Pyкy Pынкa вepyeшь? - Зaчeм жe вepoвaть в тo, чтo мoжнo нaблюдaть нeпocpeдcтвeннo?
Bitcoin mining is now a specialized and very risky industry, just like gold mining. Amateur miners are unlikely to make much money, and may even lose money. Bitcoin is much more than just mining, though!
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1713586572
Hero Member
*
Offline Offline

Posts: 1713586572

View Profile Personal Message (Offline)

Ignore
1713586572
Reply with quote  #2

1713586572
Report to moderator
1713586572
Hero Member
*
Offline Offline

Posts: 1713586572

View Profile Personal Message (Offline)

Ignore
1713586572
Reply with quote  #2

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

Activity: 326
Merit: 252



View Profile
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.

Sorry, I can't help you with your lost password.

PGP key: 0x9F31802C79642F25
bitcoinex (OP)
Sr. Member
****
Offline Offline

Activity: 350
Merit: 252


probiwon.com


View Profile WWW
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
- Moжeт, ты eщё и в Heвидимyю Pyкy Pынкa вepyeшь? - Зaчeм жe вepoвaть в тo, чтo мoжнo нaблюдaть нeпocpeдcтвeннo?
sidd
Newbie
*
Offline Offline

Activity: 13
Merit: 0


View Profile
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: 548
Merit: 502


So much code.


View Profile WWW
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.

bitcoinex (OP)
Sr. Member
****
Offline Offline

Activity: 350
Merit: 252


probiwon.com


View Profile WWW
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
- Moжeт, ты eщё и в Heвидимyю Pyкy Pынкa вepyeшь? - Зaчeм жe вepoвaть в тo, чтo мoжнo нaблюдaть нeпocpeдcтвeннo?
BrightAnarchist
Donator
Legendary
*
Offline Offline

Activity: 853
Merit: 1000



View Profile
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
Merit: 0



View Profile
March 13, 2011, 08:47:13 AM
 #8

seems to be ok now
hiker
Newbie
*
Offline Offline

Activity: 58
Merit: 0


View Profile
March 13, 2011, 07:34:42 PM
 #9

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

Activity: 14
Merit: 0


View Profile
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
Merit: 0


View Profile
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
Merit: 0


View Profile
March 15, 2011, 03:56:08 PM
 #12

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

Activity: 41
Merit: 0


View Profile
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
Merit: 61


View Profile
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 (OP)
Sr. Member
****
Offline Offline

Activity: 350
Merit: 252


probiwon.com


View Profile WWW
March 16, 2011, 10:09:06 PM
 #15

Our trading API is ok now?

New bitcoin lottery: probiwon.com
- Moжeт, ты eщё и в Heвидимyю Pyкy Pынкa вepyeшь? - Зaчeм жe вepoвaть в тo, чтo мoжнo нaблюдaть нeпocpeдcтвeннo?
ArsenShnurkov
Legendary
*
Offline Offline

Activity: 1386
Merit: 1000



View Profile
March 18, 2011, 07:11:20 PM
Last edit: March 18, 2011, 08:51:28 PM by ArsenShnurkov
 #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 (OP)
Sr. Member
****
Offline Offline

Activity: 350
Merit: 252


probiwon.com


View Profile WWW
March 18, 2011, 11:10:44 PM
Last edit: March 19, 2011, 05:20:07 AM by bitcoinex
 #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
- Moжeт, ты eщё и в Heвидимyю Pyкy Pынкa вepyeшь? - Зaчeм жe вepoвaть в тo, чтo мoжнo нaблюдaть нeпocpeдcтвeннo?
ArsenShnurkov
Legendary
*
Offline Offline

Activity: 1386
Merit: 1000



View Profile
March 19, 2011, 09:00:06 AM
Last edit: March 19, 2011, 01:56:35 PM by ArsenShnurkov
 #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
nextnonce
Member
**
Offline Offline

Activity: 74
Merit: 10


www.minethings.com


View Profile WWW
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 (OP)
Sr. Member
****
Offline Offline

Activity: 350
Merit: 252


probiwon.com


View Profile WWW
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
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

New bitcoin lottery: probiwon.com
- Moжeт, ты eщё и в Heвидимyю Pyкy Pынкa вepyeшь? - Зaчeм жe вepoвaть в тo, чтo мoжнo нaблюдaть нeпocpeдcтвeннo?
Pages: [1] 2 »  All
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!