コード例 #1
0
def GetContext():

    try:
        settings = LoadSettings()
    except:
        log.Output("Could not load settings, exiting")
        exit()

    username = str(settings['username'])
    api_key = str(settings['key'])
    api_secret = str(settings['secret'])

    try:
        context = cexapi.api(username, api_key, api_secret)

    except:
        log.Output(context)

    return context
コード例 #2
0
ファイル: CexControl.py プロジェクト: letuslook/CexControl
def GetContext():

    try:
        settings = LoadSettings()
    except:
        log.Output ("Could not load settings, exiting")
        exit()

    username    = str(settings['username'])
    api_key     = str(settings['key'])
    api_secret  = str(settings['secret'])

    try:
        context = cexapi.api(username, api_key, api_secret)

    except:
        log.Output (context)

    return context
コード例 #3
0
ファイル: bitcoin.py プロジェクト: otubo/misc
# this script gets the CEX balance and calculates the value in BRL
# using the latest value from mercadobitcoin and send a pushover
# notification to your device.

import cexapi # you can find cexapi here: https://github.com/matveyco/cex.io-api-python
import requests
import json

username = "******"
api_key = "CEX api key"
api_secret = "CEX api secret"
pushover_token = "Pushover token"
pushover_user_token = "Pushover user token"

cex_account = cexapi.api(username, api_key, api_secret)
balance = cex_account.balance()["BTC"]["available"]

mercadobitcoin_get = requests.get("http://www.mercadobitcoin.com.br/api/ticker")
bitcoin_raw = mercadobitcoin_get.content
bitcoin = json.loads(bitcoin_raw)["ticker"]["last"]

valor_em_reais = "%.2f" % (float(bitcoin) * float(balance))

message = "Hello master, your balance is R$" + str(valor_em_reais)

pushover_url='https://api.pushover.net/1/messages.json'
data= {
    'token': pushover_token,
    'user': pushover_user_token,
    'message': message
コード例 #4
0
ファイル: cexybot.py プロジェクト: SomeNewGuy/cexybot
  LTC  LgHGSjx6BHYqe6kC84wN2k2sqdXQsbQkcq
  DOGE DNSx8MSRmi1rQjUZwBiNQ7jisLLYY4RqSC
  FTC  6q4HRmiVqaCz3BBzEjfQfzp4ufCgnqVama
  AUR  ANL31J9na9qYvBNxqVUR98e5JJWVDqCEci
  NMC  N7MMZCUJ5QBmGZFWhXzeofhcvSACocBQeX
  IXC  xuNA3pakj4zVTvXUrXdvMcHiZReMenAXgq
  DVC  1PGGYrCDYRFjiKUJZxsQNMerv6WuFypmyx


"""

import cexapi
import time
from math import floor

api=cexapi.api('USERNAME','ApiKey','ApiSecret')


# sell when GHS balance reference higher by margin value in BTC
# buy  when GHS balance reference lower  by margin value in BTC
margin=.0000025

MINPRICE=.001
MAXPRICE=.03
MAXVOL=20

"""

Check market at regular interval

whenever prices rises by margin (or more) sell a chunk
コード例 #5
0
ファイル: CexControl.py プロジェクト: letuslook/CexControl
    def GetContext(self):

        return cexapi.api(self.username, self.api_key, self.api_secret)
コード例 #6
0
ファイル: test.py プロジェクト: ganders/cex.io-api-python
import cexapi

demo = cexapi.api(username, api_key, api_secret)
print "Ticker (GHS/BTC)"
print demo.ticker() ## or demo.ticker('GHS/BTC')
print "Ticker (BF1/BTC)"
print demo.ticker('BF1/BTC')
print "Order book (GHS/BTC)"
print demo.order_book() ## or demo.order_book('GHS/BTC')
print "Order book (BF1/BTC)"
print demo.order_book('BF1/BTC')
print "Trade history since=100 (GHS/BTC)"
print demo.trade_history(100) ## or (100,'GHS/BTC')
print "Trade history since=100 (BF1/BTC)"
print demo.trade_history(100,'BF1/BTC')
print "Balance"
print demo.balance()
print "Open orders (GHS/BTC)"
print demo.current_orders() ## or ('GHS/BTC')
print "Open orders (BF1/BTC)"
print demo.current_orders('BF1/BTC')
print "Cancel order (order_id=100)"
print demo.cancel_order(100)
print "Plaсe order buy 4GHS/0.1BTC)"
print demo.place_order('buy',1,0.1) ## or ('buy',1,0.1,'GHS/BTC')
print "Open orders sell 1BF1/1.5BTC"
print demo.place_order('sell',1,1.5,'BF1/BTC')
print "Hashrate"
print demo.hashrate()
print "Workers"
print demo.workers()
コード例 #7
0
    def GetContext(self):

        return cexapi.api(self.username, self.api_key, self.api_secret)
コード例 #8
0
# -*- coding: utf-8 -*-
import cexapi

demo = cexapi.api(username, api_key, api_secret)
print "Ticker (GHS/BTC)"
print demo.ticker()  ## or demo.ticker('GHS/BTC')
print "Ticker (BF1/BTC)"
print demo.ticker('BF1/BTC')
print "Order book (GHS/BTC)"
print demo.order_book()  ## or demo.order_book('GHS/BTC')
print "Order book (BF1/BTC)"
print demo.order_book('BF1/BTC')
print "Trade history since=100 (GHS/BTC)"
print demo.trade_history(100)  ## or (100,'GHS/BTC')
print "Trade history since=100 (BF1/BTC)"
print demo.trade_history(100, 'BF1/BTC')
print "Balance"
print demo.balance()
print "Open orders (GHS/BTC)"
print demo.current_orders()  ## or ('GHS/BTC')
print "Open orders (BF1/BTC)"
print demo.current_orders('BF1/BTC')
print "Cancel order (order_id=100)"
print demo.cancel_order(100)
print "Plaсe order buy 4GHS/0.1BTC)"
print demo.place_order('buy', 1, 0.1)  ## or ('buy',1,0.1,'GHS/BTC')
print "Open orders sell 1BF1/1.5BTC"
print demo.place_order('sell', 1, 1.5, 'BF1/BTC')
コード例 #9
0
ファイル: buybot.py プロジェクト: andrewhager9/BuyBot
# -*- coding: utf-8 -*-
import cexapi
import os
from time import sleep

print 'Started Buybot V1.0 Buys at 0.00001 or more BTC'
print 'Loading Config...'
print ''
confg = open('buybot.ini', 'r')
refresh = int(confg.readline().split(':')[1])
usrname = confg.readline().split(':')[1].rstrip()
api_pub = confg.readline().split(':')[1].rstrip()
api_pri = confg.readline().split(':')[1].rstrip()
confg.close()
cex = cexapi.api(usrname, api_pub, api_pri)
loopcount = 1.0
print 'Now Starting up!'
sleep(2)
os.system('cls')
while (loopcount < 100000):
    f = open('buybot.log', 'w')
    print 'Loop number %10.0f' % loopcount
    print '\n\n\n\n\n\n\n\n\n'
    btcf = float(cex.balance()['BTC']['available'])
    buyp = float(cex.ticker('GHS/BTC')['last'])
    print 'BTC Balance %6.6F' % btcf
    if (btcf > 0.00001):
        buyamount = btcf / buyp
        print cex.place_order('buy', buyamount, buyp, 'GHS/BTC')
        print 'Bought %2.8F GH/s at %1.8F BTC' % buyamount, buyp
        f.write('Bought %2.8F GH/s at %1.8F BTC' % buyamount, buyp)
コード例 #10
0
# this script gets the CEX balance and calculates the value in BRL
# using the latest value from mercadobitcoin and send a pushover
# notification to your device.

import cexapi  # you can find cexapi here: https://github.com/matveyco/cex.io-api-python
import requests
import json

username = "******"
api_key = "CEX api key"
api_secret = "CEX api secret"
pushover_token = "Pushover token"
pushover_user_token = "Pushover user token"

cex_account = cexapi.api(username, api_key, api_secret)
balance = cex_account.balance()["BTC"]["available"]

mercadobitcoin_get = requests.get(
    "http://www.mercadobitcoin.com.br/api/ticker")
bitcoin_raw = mercadobitcoin_get.content
bitcoin = json.loads(bitcoin_raw)["ticker"]["last"]

valor_em_reais = "%.2f" % (float(bitcoin) * float(balance))

message = "Hello master, your balance is R$" + str(valor_em_reais)

pushover_url = 'https://api.pushover.net/1/messages.json'
data = {
    'token': pushover_token,
    'user': pushover_user_token,
コード例 #11
0
ファイル: buybot.py プロジェクト: deleojr/BuyBot
# -*- coding: utf-8 -*-
import cexapi
import os
from time import sleep
print 'Started Buybot V1.0 Buys at 0.00001 or more BTC'
print 'Loading Config...'
print ''
confg = open('buybot.ini','r')
refresh = int(confg.readline().split(':')[1])
usrname = confg.readline().split(':')[1].rstrip()
api_pub = confg.readline().split(':')[1].rstrip()
api_pri = confg.readline().split(':')[1].rstrip()
confg.close()
cex = cexapi.api(usrname, api_pub, api_pri)
loopcount = 1.0
print 'Now Starting up!'
sleep(2)
os.system('cls')
while(loopcount < 100000):
	f = open('buybot.log','w')
	print 'Loop number %10.0f' % loopcount
	print '\n\n\n\n\n\n\n\n\n'
	btcf = float(cex.balance()['BTC']['available'])
	buyp = float(cex.ticker('GHS/BTC')['last'])
	print 'BTC Balance %6.6F' % btcf
	if(btcf > 0.00001):
		buyamount = btcf/buyp	
		print cex.place_order('buy',buyamount,buyp,'GHS/BTC')
		print 'Bought %2.8F GH/s at %1.8F BTC' % buyamount,buyp
		f.write('Bought %2.8F GH/s at %1.8F BTC' % buyamount,buyp)
	else: