Bitcoin Forum
June 16, 2024, 08:36:56 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
  Home Help Search Login Register More  
  Show Posts
Pages: [1]
1  Economy / Marketplace / [selling] Used RAM and GFX card - UK only on: March 31, 2011, 06:54:16 PM
2x512MB Geil DDR400 - 10 BTC

Gigabyte Fanless AGP GeForce 6600 GV-N66256DP - 15 BTC

Prices include UK delivery.
2  Economy / Trading Discussion / Re: Trading bot? on: March 14, 2011, 09:14:52 PM
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"
3  Economy / Trading Discussion / Re: Trading bot? on: March 07, 2011, 02:43:27 PM
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"}]
4  Bitcoin / Pools / Re: Cooperative mining (>10000Mhash/s, join us!) on: January 31, 2011, 05:15:14 PM
Have you introduced some problem with the distribution of work? The probability of finding so few blocks over the last 20 hours is about 10^-5 ...
5  Bitcoin / Pools / Re: Cooperative mining (>10000Mhash/s, join us!) on: January 31, 2011, 01:10:29 PM
Your new system is totally fair in terms of expected value. You might want to increase the number of shares, this will reduce the variance for the CPU miners.
6  Economy / Marketplace / Re: Announcing BTCSportsBet.com - New Sportsbook + free coins offer inside! on: January 29, 2011, 10:21:04 PM
Could we get odds in decimals?
7  Bitcoin / Bitcoin Discussion / Re: Tragedy Of The Commons on: January 28, 2011, 09:48:17 PM
Mining is kind of like a dollar auction. The only method of winning is to persuade everyone else to stop playing and let you have the final bid.
8  Bitcoin / Bitcoin Discussion / Re: Abusing Bitcoin mining pools: strategies for egoistical but honest miners on: January 28, 2011, 01:41:10 PM
All the pool has to do to prevent this type of abuse is weight the reward of the shares by exp( current shares / difficulty )
9  Bitcoin / Project Development / Re: BTC Options exchange and clearing on: January 27, 2011, 10:13:39 PM
It would be even better if it could be linked to a mining pool. That way a trader could demonstrate that the huge liability possible with some options is entirely covered by their own mining.
10  Economy / Marketplace / Re: List of honest traders. on: January 27, 2011, 08:52:24 PM
I'll nominate you if you nominate me  Smiley

In all seriousness Vladimir's $3k worth of trustworthy. Plus I know where he lives.
11  Economy / Marketplace / Re: Options trading on: January 27, 2011, 08:02:46 PM
I've set up 1 Ghash/sec mining and am now offering discount call options in limited quantity. My expected return from selling these is negative, but it improves my profit distribution from the mining. Anyone who's feeling bullish should be interested.

All payments in BTC only

Current rate for 30 day at-the-money (0.45) is 0.38, any strike rate and period up to 6 months available.

You pay 0.38 BTC, after 30 days I pay (1 - strike price/expiry price) BTC
12  Economy / Marketplace / Re: Options trading on: January 26, 2011, 06:30:00 PM
@TTBit:
 sounds reasonable. What about a 30c put?

@sgornik:
I don't see how an escrow can help much here. For the call, I can't put my 7500 BTC in escrow because I haven't mined it yet. For the put, he would have to keep $1500 in escrow for 6 months just to collect $150, which is barely worth it.
13  Economy / Marketplace / Options trading on: January 26, 2011, 04:08:00 PM
I'm financing some mining and would like some insurance against the value of bitcoins dropping considerably.

I'm looking to make either:
a) An American style long put, strike rate of 1 BTC = 0.2 USD, premium in either currency either in advance or at expiry.
b) A European style short call, strike rate of 1 BTC = 0.5 USD, premium in BTC in advance, or USD at any time.

In each case the expiration date will be 6 months and the quantity any part or parts up to 7500 BTC.

Is anyone able to offer a competitive premium for these types of option? Is there a way of conducting these trades so as to minimize counterparty risk?


Pages: [1]
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!