logging.config.fileConfig('logging.ini') # create Binance object bn = Binance() # set keys bn.setSecretKey('NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j') bn.setAPIKey('vmPUZE6mv9SD5VNHk4HlWFsOr6aKE2zvsw0MuIgwCIPy6utIco14y7Ju91duEh8A') # createOrder print "---------------- createOrder --------------" print "################################# POSITIVE TESTS (returns 1 or r) ###################" queryParams = {'symbol':'SALTBTC','side':'BUY','type':'LIMIT','timeInForce':'GTC','quantity':1.0,'price':2.0} print "****test valid mandatory inputs" test = bn.createOrder(queryParams) print queryParams = {'symbol':'SALTBTC','side':'BUY','type':'LIMIT','timeInForce':'GTC','quantity':1.0,'price':2.0,'newClientOrderId':'123456778'} print "****test valid mandatory inputs plus some optional" test = bn.createOrder(queryParams) print queryParams = {'symbol':'SALTBTC','side':'BUY','type':'LIMIT','timeInForce':'GTC','quantity':1.0,'price':2.0,'newClientOrderId':'223456778'} print "****test valid mandatory inputs plus some optional" test = bn.createOrder(queryParams) print queryParams = {'stopPrice':3.0,'symbol':'SALTBTC','side':'BUY','type':'LIMIT','timeInForce':'GTC','quantity':1.0,'price':2.0,'newClientOrderId':'223456778'} print "****test valid mandatory inputs plus some optional" test = bn.createOrder(queryParams) print queryParams = {'icebergQty':10.5,'stopPrice':3.0,'symbol':'SALTBTC','side':'BUY','type':'LIMIT','timeInForce':'GTC','quantity':1.0,'price':2.0,'newClientOrderId':'223456778'} print "****test valid mandatory inputs plus some optional"
config = ConfigParser.ConfigParser() config.read("config.ini") return config.get('KEYS', key) queryParams = {} queryParams[ 'symbol'] = 'XVGBTC' # start with a cheap asset so if you goof it won't be terrible queryParams['side'] = 'BUY' #queryParams['type'] = 'LIMIT' queryParams['type'] = 'MARKET' queryParams['timeInForce'] = 'GTC' queryParams['quantity'] = 1.0 queryParams['price'] = 0.0000005 # this logging configuration is sketchy binance = logging.getLogger(__name__) logging.config.fileConfig('logging.ini') # create Binance object bn = Binance() # set keys bn.setSecretKey(readConfig('secret')) bn.setAPIKey(readConfig('apikey')) myorder = bn.createOrder(queryParams, True) # the testFlag=True here makes it a test #myorder = bn.createOrder(queryParams) # the absense of testFlag makes this execute a trade print myorder