Exemplo n.º 1
0
    def __init__(self, quantity, key, secret):
        self.quantity = quantity
        self.commission = .2

        from bitfinex.client import Client, TradeClient
        self.privateWrapper = TradeClient(key, secret)
        self.publicWrapper = Client()
Exemplo n.º 2
0
class TestTradeClient(unittest.TestCase):
    def setUp(self):
        self.tc = TradeClient(API_KEY, API_SECRET)

    def test_instantiate_tradeclient(self):
        self.assertIsInstance(self.tc, TradeClient)

    def test_get_active_orders_returns_json(self):
        ao = self.tc.active_orders()
        self.assertIsInstance(ao, list)

    def test_get_active_positions_returns_json(self):
        ap = self.tc.active_positions()
        self.assertIsInstance(ap, list)

    def test_get_full_history(self):
        ap = self.tc.active_positions()
        self.assertIsInstance(ap, list)
Exemplo n.º 3
0
class TestTradeClient(unittest.TestCase):
    def setUp(self):
        self.tc = TradeClient(API_KEY, API_SECRET)

    def test_instantiate_tradeclient(self):
        self.assertIsInstance(self.tc, TradeClient)

    def test_get_active_orders_returns_json(self):
        ao = self.tc.active_orders()
        self.assertIsInstance(ao, list)

    def test_get_active_positions_returns_json(self):
        ap = self.tc.active_positions()
        self.assertIsInstance(ap, list)

    def test_get_full_history(self):
        ap = self.tc.active_positions()
        self.assertIsInstance(ap, list)
Exemplo n.º 4
0
class BFX(object):
    def __init__(self, quantity, key, secret):
        self.quantity = quantity
        self.commission = .2

        from bitfinex.client import Client, TradeClient
        self.privateWrapper = TradeClient(key, secret)
        self.publicWrapper = Client()

    def getCommission(self):
        return self.commission

    def getSpotPrice(self, ticker='btcusd'):
        return self.publicWrapper.ticker(ticker)['last_price']

    def goLong(self):
        price = self.getSpotPrice()
        order = self.privateWrapper.place_order(self.quantity, price, 'buy',
                                                'exchange market')
        import time
        time.sleep(.25)
Exemplo n.º 5
0
 def setUp(self):
     self.tc = TradeClient(API_KEY, API_SECRET)
Exemplo n.º 6
0
 def setUp(self):
     self.tc = TradeClient(API_KEY, API_SECRET)
Exemplo n.º 7
0
from sqlalchemy import *
import time
import numpy as np
from decimal import Decimal
# using bitfinex APIs to get today's_ticker
from bitfinex.client import Client, TradeClient
client = Client()
trade = TradeClient('K4HJultQmdvroWCnNy5OMcXx7QfGoQgZw0vrkWmuV1Y',
                    'dFt4tsMFszh2vTGGvHqFEP3fkaaSniJ4zDA4pSWyJOM')

# we are inporting the Databse that is being created by bitfinex-boat

engine = create_engine('sqlite:////home/metal-machine/Desktop/all_ticker.db')
metadata = MetaData(engine)
tickers = Table('ticker', metadata, autoload=True)


def find_nearest(array, value):
    """ gets the numpy array and timestamp as input and retunrs the nearest value"""

    idx = np.abs(array - value).argmin()
    return array[idx]


def ohlc_past(hours):
    """This function returns the seconds as input and retrun the required ohlc_4"""

    seconds = 3600 * hours  # converting hours into seconds
    time_delta = float('{:7f}'.format(time.time() - seconds))
    time_stamp = tickers.select(tickers.c.timestamp)
    timestamp_array = np.array([i[1] for i in time_stamp.execute()])
Exemplo n.º 8
0
from sqlalchemy import *
import time
import numpy as np
from decimal import Decimal
# using bitfinex APIs to get today's_ticker
from bitfinex.client import Client, TradeClient
trade = TradeClient('TlwqyZCq6tcr7kG25WLlPKk1IKvYoRndgr16mQ4qTQh',
                    'yPiilMjqCutpEptu7a1etlJmmHMuaru83wa9qqQOlhb')

print trade.balances()

client = Client()
#trade = TradeClient('K4HJultQmdvroWCnNy5OMcXx7QfGoQgZw0vrkWmuV1Y','dFt4tsMFszh2vTGGvHqFEP3fkaaSniJ4zDA4pSWyJOM')

# we are inporting the Databse that is being created by bitfinex-boat

engine = create_engine('sqlite:////home/metal-machine/Desktop/all_ticker.db')
metadata = MetaData(engine)
tickers = Table('ticker', metadata, autoload=True)


def find_nearest(array, value):
    """ gets the numpy array and timestamp as input and retunrs the nearest value"""

    idx = np.abs(array - value).argmin()
    return array[idx]


def ohlc_past(hours):
    """This function returns the seconds as input and retrun the required ohlc_4"""