Ejemplo n.º 1
0
 def testConstructURLWithPort(self):
     options = {
         'port': 40000
     }
     api = BitX('', '', options)
     url = api.construct_url('test')
     self.assertEqual(url, 'https://api.mybitx.com:40000/api/1/test')
Ejemplo n.º 2
0
 def testConstructURLWithHost(self):
     options = {
         'hostname': 'localhost',
     }
     api = BitX('', '', options)
     url = api.construct_url('test')
     self.assertEqual(url, 'https://localhost/api/1/test')
Ejemplo n.º 3
0
 def testCustomOptionsAndAuth(self):
     options = {'hostname': 'localhost', 'port': 8000, 'pair': 'XBTUSD'}
     key = 'abc'
     secret = '123'
     api = BitX(key, secret, options)
     self.assertEqual(api.hostname, options['hostname'])
     self.assertEqual(api.port, options['port'])
     self.assertEqual(api.pair, options['pair'])
     self.assertEqual(api.auth, (key, secret))
Ejemplo n.º 4
0
 def testCustomOptionsAndAuth(self):
     options = {'hostname': 'localhost', 'port': 8000, 'pair': 'XBTUSD'}
     key = 'cnz2yjswbv3jd'
     secret = '0hydMZDb9HRR3Qq-iqALwZtXLkbLR4fWxtDZvkB9h4I'
     api = BitX(key, secret, options)
     self.assertEqual(api.hostname, options['hostname'])
     self.assertEqual(api.port, options['port'])
     self.assertEqual(api.pair, options['pair'])
     self.assertEqual(api.auth, (key, secret))
Ejemplo n.º 5
0
 def setUp(self):
     options = {
         'hostname': 'api.dummy.com',
         'pair': 'XBTZAR'
     }
     key = 'mykey'
     secret = 'mysecret'
     self.api = BitX(key, secret, options)
     self.auth_string = TestAPICalls.make_auth_header(self.api.auth)
Ejemplo n.º 6
0
def runDemo():
    user = ''
    password = ''
    auth = 'BITX_KEY' in os.environ and 'BITX_SECRET' in os.environ
    if auth:
        user = os.environ['BITX_KEY']
        password = os.environ['BITX_SECRET']
    else:
        print "Note: I couldn't find a BITX_KEY environment variable. This means that none of the API queries\nthat " \
              "require authentication will work. I'll carry on anyway, but make sure your credentials are available " \
              "in the BITX_KEY and BITX_SECRET environment variables and run this demo again"
    api = BitX(user, password)
    kind = 'auth' if auth else 'none'
    format_call('  Ticker   ', api.get_ticker(kind))
    format_call('All Tickers', api.get_all_tickers(kind))
    format_call('Order book ', api.get_order_book(5, kind))
    format_call('   Trades  ', api.get_trades(10, kind))
    if auth:
        format_call('   Orders  ', api.get_orders())
        format_call('Funding address', api.get_funding_address('XBT'))
        format_call('   Balance ', api.get_balance())
Ejemplo n.º 7
0
 def testConstructor(self):
     api = BitX('', '', {})
     self.assertTrue(isinstance(api, BitX))
Ejemplo n.º 8
0
 def testConstructURL(self):
     api = BitX('', '')
     url = api.construct_url('test')
     self.assertEqual(url, 'https://api.mybitx.com/api/1/test')
Ejemplo n.º 9
0
 def testOptions(self):
     api = BitX('', '')
     self.assertEqual(api.hostname, 'api.mybitx.com')
     self.assertEqual(api.port, 443)
     self.assertEqual(api.pair, 'XBTZAR')
Ejemplo n.º 10
0
def setup_api():
    #   Log in to Luno, Settings, API codes, Generate new, Specify permitions, copy username and password code.
    user = '******'
    password = '******'
    api = BitX(user, password)
    return api