예제 #1
0
import time
import urllib2
from lib.client import Client, get_api_path

client = Client(access_key='', secret_key='')

#demo of GET APIs

#get member info
print client.get(get_api_path('members'))

#get markets
markets =  client.get(get_api_path('markets'))
print "markets:", markets

#get tickers of each market
#market should be specified in url
print 
print "tickers in markets"
for market in markets:
    print client.get(get_api_path('tickers') % market['id'])

#get orders of each market
#market should be specified in params
print 
print "orders in markets"
for market in markets:
    print client.get(get_api_path('orders'), {'market': market['id']})

#get order book
print client.get(get_api_path('order_book'), params={'market': 'btccny'})
예제 #2
0
import time
import urllib2
from lib.client import Client, get_api_path

client = Client(access_key='your access key', secret_key='your secret key')

#demo of GET APIs

#get member info
print client.get(get_api_path('members'))

#get markets
markets =  client.get(get_api_path('markets'))
print "markets:", markets

#get tickers of each market
#market should be specified in url
print 
print "tickers in markets"
for market in markets:
    print client.get(get_api_path('tickers') % market['id'])

#get orders of each market
#market should be specified in params
print 
print "orders in markets"
for market in markets:
    print client.get(get_api_path('orders'), {'market': market['id']})

#get order book
print client.get(get_api_path('order_book'), params={'market': 'btcaud'})
예제 #3
0
                                          size=None)
        sellloginverse = aloginverse * sellprice

        amround = round(sellloginverse, 2)
        avolumne = round(((np.random.uniform(1, 10)) / 10000), 8)
        sellTotal = round((amround * avolumne), 8)

        print("Sell BTC  -->", amround, avolumne, sellTotal)

        sellparams = {
            'market': 'btcusd',
            'side': 'sell',
            'volume': avolumne,
            'price': amround
        }
        rsell = sellsession.post(get_api_path('orders'), sellparams)

        status_code = 200
        print("Order Sell Page")
        if status_code == 200:
            sellscount = sellscount + 1

        bloginverse = np.random.lognormal(mean=buymean,
                                          sigma=buysigma,
                                          size=None)
        buyloginverse = bloginverse * buyprice
        bmround = round(buyloginverse, 2)

        bvolumne = round(((np.random.uniform(1, 10)) / 10000), 8)
        buyTotal = round((bmround * bvolumne), 8)
예제 #4
0
def runTrade():
    global tradeflag
    print(tradeflag)
    client1 = Client(access_key='XcFvxAdM1iupNh3Q0glbzicvm3ASMEEhzmQjQ7MB',
                     secret_key='anE8jZd9o8p6FEj2xScdQUAY4Hjhf6jXxFsyXuSg')
    client2 = Client(access_key='NB9bgKQtz4aMUqTVr8lDjFaUTD15KMjxCZCWHP6q',
                     secret_key='nkZDYvX1pBj05MEUxBBIZcPQScxmjpxNcEaljAEh')

    sellmean = 0.1
    sellsigma = 0.1
    sellprice = 1000

    buymean = 0.1
    buysigma = 0.03
    buyprice = 1010

    buyscount = 0
    sellscount = 0
    total = 0
    errorcount500 = 0

    buysession = client2
    sellsession = client1
    x = 0
    try:
        while tradeflag:
            time.sleep(2)

            x = x + 1

            if x % 2 == 0:
                buysession = client2
                sellsession = client1
            else:
                buysession = client1
                sellsession = client2

            aloginverse = np.random.lognormal(mean=sellmean,
                                              sigma=sellsigma,
                                              size=None)
            sellloginverse = aloginverse * sellprice

            amround = round(sellloginverse, 2)
            avolumne = round(((np.random.uniform(1, 10)) / 10000), 8)
            sellTotal = round((amround * avolumne), 8)

            print("Sell BTC  -->", amround, avolumne, sellTotal)

            sellparams = {
                'market': 'btcusd',
                'side': 'sell',
                'volume': avolumne,
                'price': amround
            }
            try:
                rsell = sellsession.post(get_api_path('orders'), sellparams)
            except Exception as exp:
                print("json parsing error")

            status_code = 200
            print("Order Sell Page")
            if status_code == 200:
                sellscount = sellscount + 1

            bloginverse = np.random.lognormal(mean=buymean,
                                              sigma=buysigma,
                                              size=None)
            buyloginverse = bloginverse * buyprice
            bmround = round(buyloginverse, 2)

            bvolumne = round(((np.random.uniform(1, 10)) / 10000), 8)
            buyTotal = round((bmround * bvolumne), 8)

            time.sleep(0.2)

            print("buy  -->", bmround, bvolumne, buyTotal)

            buyparams = {
                'market': 'btcusd',
                'side': 'buy',
                'volume': bvolumne,
                'price': bmround
            }
            try:
                rbuy = buysession.post(get_api_path('orders'), buyparams)
            except Exception as exp:
                print("json parsing error")

            print("Order Buy Page")
            if status_code == 200:
                buyscount = buyscount + 1

            total = total + 1

            if (status_code == 500) or (status_code == 500):
                errorcount500 = errorcount500 + 1

            time.sleep(0.2)

    except Exception as ex:
        print(str(ex))
        print("Error Occured after iteration number ", total)
    finally:
        print("total --> ", total)
        print("buys --> ", buyscount)
        print("sells --> ", sellscount)
        print("500 Error Count --> ", errorcount500)
예제 #5
0
import time
import urllib2
from lib.client import Client, get_api_path

client = Client(access_key="your access key", secret_key="your secret key")

# demo of GET APIs

# get member info
print client.get(get_api_path("members"))

# get markets
markets = client.get(get_api_path("markets"))
print "markets:", markets

# get tickers of each market
# market should be specified in url
print
print "tickers in markets"
for market in markets:
    print client.get(get_api_path("tickers") % market["id"])

# get orders of each market
# market should be specified in params
print
print "orders in markets"
for market in markets:
    print client.get(get_api_path("orders"), {"market": market["id"]})

# get order book
print client.get(get_api_path("order_book"), params={"market": "btccny"})
예제 #6
0
import time
import urllib.request

from lib.client import Client, get_api_path

client = Client(access_key='', secret_key='')

#demo of GET APIs

#get member info
print(client.get(get_api_path('members')))

#get markets
markets =  client.get(get_api_path('markets'))
print("markets:", markets)

#get tickers of each market
#market should be specified in url
print()
print("tickers in markets")
# for market in markets:
#     print(market)
#     print(client.get(get_api_path('tickers') % market['id']))

print(client.public_get(get_api_path('tickers')%'btccny'))
#get orders of each market
#market should be specified in params
# print ()
# print("orders in markets")
# for market in markets:
#     print (client.get(get_api_path('orders'), {'market': market['id']}))
예제 #7
0
import time
import urllib2
import sys
import json

from lib.client import Client, get_api_path

client = Client(access_key='ZURvhizTAkcw2aYcnYQ9Jn3CYKNREeDcNdl1HXlp',
                secret_key='TYJeyNkXH1y7CD3xW64u6NbNsfgdIwJmlPfzsx58')
#client = Client(access_key='E4xWabtFKMWrj2YAwIyg3LHIml0ACLP2Cr1', secret_key='3p33k2yF22lE0nHJxwr5lN8R1gu44cBC6JV')

#####################
#get member info
#########################
member = (client.get(get_api_path('members')))
print "Name:", member['name']
print "memo:", member['memo']
print "sn:", member['sn']
print "email:", member['email']
print "active:", member['activated']
print "Account:"
for i in range(0, len(member['accounts'])):
    print "       ", member['accounts'][i]['currency'], "Balance: ", member[
        'accounts'][i]['balance'], "Locked: ", member['accounts'][i]['locked']

print
print

#####################
#get markets
######################
예제 #8
0
import time
import urllib.request
import urllib.error
import urllib

from lib.client import Client, get_api_path

client = Client(access_key='ACCESS_KEY', secret_key='SECRET_KEY')

#demo of GET APIs

#get member info
print ("memo")
print (client.get(get_api_path('members'),None, True))

#get markets
markets =  client.get(get_api_path('markets'))
print ("markets:", markets)

#get tickers of each market
print ("tickers in markets")
print (client.get(get_api_path('tickers') % 'btscny'))

for market in markets:
    print(str(market["id"]))
    print (client.get(get_api_path('tickers') % market["id"]))

print (client.get(get_api_path('orders'), {'market':'daocny'}, True))

#get orders of each market
#market should be specified in params