예제 #1
0
파일: diffscalp.py 프로젝트: brinchj/mtgox
import time

from mtgoxcore import MtGoxCore
from tradehillcore import TradehillCore
from decimal import Decimal

GOXFEE = Decimal("0.0053")
HILFEE = Decimal("0.0054")  # Referral code

gox = MtGoxCore()
hil = TradehillCore()

while True:
    goxtick = gox.ticker()["ticker"]
    hiltick = hil.ticker()["ticker"]
    goxsell = Decimal(goxtick["buy"]) * (1 - GOXFEE)
    goxbuy = Decimal(goxtick["sell"]) / (1 - GOXFEE)
    hilsell = Decimal(hiltick["buy"]) * (1 - HILFEE)
    hilbuy = Decimal(hiltick["sell"]) / (1 - HILFEE)
    if hilbuy < goxsell:
        print time.ctime(time.time())
        print "  Buy on Tradehill for %.3f, sell on MtGox for %.3f --\
 make %.2f%% profit!" % (
            hilbuy,
            goxsell,
            100 * (goxsell - hilbuy) / hilbuy,
        )
    if goxbuy < hilsell:
        print time.ctime(time.time())
        print "  Buy on MtGox for %.3f, sell on Tradehill for %.3f --\
 make %.2f%% profit!" % (
예제 #2
0
파일: ticker.py 프로젝트: brinchj/mtgox

import time, convert, pynotify, logging

from mtgoxcore import MtGoxCore
from config import KEY, SEC
from decimal import Decimal

FEE = Decimal('0.0043')

gox = MtGoxCore(KEY, SEC)
bal = convert.balance(gox.balance())
#bal = {'btcs': Decimal(40), 'usds': Decimal(0)}
while True:
    try:
        tic = convert.ticker(gox.ticker())
        newbal = convert.balance(gox.balance())

        last = tic['last']
        buy = tic['sell']
        sell = tic['buy']
        usds = bal['usds']
        btcs = bal['btcs']
        newusds = newbal['usds']
        newbtcs = newbal['btcs']
        valusds = (1 - FEE) * newbtcs * last + newusds
        valbtcs = (1 - FEE) * newusds / last + newbtcs
        print '%.3f BTC + %.3f USD' % (newbtcs, newusds)
        print '%.3f BTC / %.3f USD' % (valbtcs, valusds)
        print 'Buy %.3f - Sell %.3f - Last %.3f' % (buy, sell, last)
        print ''