コード例 #1
0
    def create_order(self, cur, coin, amount, price, dir):
        """
            Create a trade order.
            In bitfinex direction is indicated by amount being positive or negative.

            :param cur
                Currency to user to create the trade order.
            :param coin
                Coin to use to create the trade order.
            :param amount
                Amount to be used to create the order. If the direction equal "buy"
                amount is positive, else if direction equals "sell"
                amount is negative or multiplied by -1.
            :param price
                Price to use to create the trade order.
            :param dir
                Unused paramenter, kept for compatibility.
        """
        endpoint = "/api/{}/{}_{}".format(dir, cur, coin)
        payload = {
            "amount": amount,
            "price": price,
            "ioc_order": True
        }
        headers = self.create_signature_headers(endpoint, payload)
        req = Request(base_url, endpoint)
        rsl = req.post(headers, payload)
        if "error" in rsl.keys():
            logging.error(rsl)
        logging.info(rsl)
        return rsl
コード例 #2
0
 def get_book(cls, pair):
     """Get order book from exchange."""
     endpoint = "/api/order_book/{}".format(pair)
     for pair in cls.get_symbols():
         req = Request(base_url, endpoint)
         rsl = req.get()
         return rsl
コード例 #3
0
    def create_order(self, cur, coin, amount, price, dir):
        """
            Create a trade order.
            In bitfinex direction is indicated by amount being positive or negative.

            :param cur
                Currency to user to create the trade order.
            :param coin
                Coin to use to create the trade order.
            :param amount
                Amount to be used to create the order. If the direction equal "buy"
                amount is positive, else if direction equals "sell"
                amount is negative or multiplied by -1.
            :param price
                Price to use to create the trade order.
            :param dir
                Unused paramenter, kept for compatibility.
        """
        suffix = "/v2/trading/placeOrder"
        payload = {
            "instrument": "{}-{}".format(coin, cur),
            "side": dir,
            "volume": amount,
            "price": price
        }
        headers = self.create_signature_headers(suffix)
        req = Request(base_url, suffix)
        rsl = req.post(headers, payload)
        order_id = rsl["id"]
        time.sleep(10)
        cancelled = self.cancel_order(order_id)
        return cancelled
コード例 #4
0
ファイル: bitfinex.py プロジェクト: FliCrz/tickers-py
    def create_order(self, cur, coin, amount, price, dir):
        """
            Create a trade order.
            In bitfinex direction is indicated by amount being positive or negative.

            :param cur
                Currency to user to create the trade order.
            :param coin
                Coin to use to create the trade order.
            :param amount
                Amount to be used to create the order. If the direction equal "buy"
                amount is positive, else if direction equals "sell"
                amount is negative or multiplied by -1.
            :param price
                Price to use to create the trade order.
            :param dir
                Unused paramenter, kept for compatibility.
        """
        endpoint = "/v2/auth/w/order/submit"
        if dir == "sell":
            amount = float(amount) * -1

        data = {
            "type": "IOC",
            "symbol": "t{}{}".format(coin, cur),
            "price": price,
            "amount": amount
        }
        headers = self.create_signature_headers(endpoint, data)
        req = Request(api_auth_url, endpoint)
        rsl = req.post(headers, data)
        if len(rsl) >= 7:
            return rsl[7]
        logging.info(rsl)
        return rsl[2]
コード例 #5
0
ファイル: okex.py プロジェクト: FliCrz/tickers-py
    def create_order(self, cur, coin, amount, price, dir):
        """
            Create a trade order.
            In bitfinex direction is indicated by amount being positive or negative.

            :param cur
                Currency to user to create the trade order.
            :param coin
                Coin to use to create the trade order.
            :param amount
                Amount to be used to create the order. If the direction equal "buy"
                amount is positive, else if direction equals "sell"
                amount is negative or multiplied by -1.
            :param price
                Price to use to create the trade order.
            :param dir
                Unused paramenter, kept for compatibility.
        """
        suffix = "/api/spot/v3/orders"
        data = {
            "type": "limit",
            "side": dir,
            "instrument_id": "{}-{}".format(coin, cur),
            "size": amount,
            "price": price,
            "order_type": 3
        }
        headers = self.create_signature_headers(suffix, data)
        req = Request(base_url, suffix)
        rsl = req.post(headers, data)
        if rsl["result"] == True:
            return True
        return False
コード例 #6
0
    def create_order(self, cur, coin, amount, price, dir):
        """
            Create a trade order.
            In bitfinex direction is indicated by amount being positive or negative.

            :param cur
                Currency to user to create the trade order.
            :param coin
                Coin to use to create the trade order.
            :param amount
                Amount to be used to create the order. If the direction equal "buy"
                amount is positive, else if direction equals "sell"
                amount is negative or multiplied by -1.
            :param price
                Price to use to create the trade order.
            :param dir
                Unused paramenter, kept for compatibility.
        """
        suffix = "/v1/Trade/OrderSubmit"    
        nonce = str(int(time.time() * 1000))
        data = {
            "nonce": nonce,
            "market": "{}_{}".format(coin, cur),
            "orderType": "Limit",
            "type": dir,
            "amount": amount,
            "price": price,
        }
        headers = self.create_signature_headers({"data": data})
        req = Request(base_url, suffix)
        rsl = req.post(headers, data)
        order_id = rsl["orderId"]
        if not order_id: return False
        return self.cancel_order(order_id)
コード例 #7
0
ファイル: livecoin.py プロジェクト: FliCrz/tickers-py
    def create_order(self, cur, coin, amount, price, dir):
        """
            Create a trade order.
            In bitfinex direction is indicated by amount being positive or negative.

            :param cur
                Currency to user to create the trade order.
            :param coin
                Coin to use to create the trade order.
            :param amount
                Amount to be used to create the order. If the direction equal "buy"
                amount is positive, else if direction equals "sell"
                amount is negative or multiplied by -1.
            :param price
                Price to use to create the trade order.
            :param dir
                Unused paramenter, kept for compatibility.
        """
        suffix = "/exchange/{}limit".format(dir)
        data = {
            "currencyPair": "{}/{}".format(coin, cur),
            "price": price,
            "quantity": amount
        }
        req = Request(base_url, suffix)
        headers = self.create_signature_headers(suffix, data)
        rsl = req.post(headers, data)
        if rsl["success"] == True:
            return True
        return False
コード例 #8
0
ファイル: bitforex.py プロジェクト: FliCrz/tickers-py
 def get_symbols(cls):
     """Get available trading symbols."""
     endpoint = "/api/v1/market/symbols"
     req = Request(base_url, endpoint)
     data = req.get()
     for i in data["data"]:
         yield i["symbol"]
コード例 #9
0
ファイル: livecoin.py プロジェクト: FliCrz/tickers-py
 def get_balances(self):
     """Get Balances from exchange"""
     suffix = "/payment/balances"
     req = Request(base_url, suffix)
     headers = self.create_signature_headers(suffix)
     rsl = req.get(headers=headers)
     parser = Normalizer(rsl)
     return parser.normalize_balances
コード例 #10
0
 def get_balances(self):
     """Get Balances from exchange"""
     suffix = "/api/v1/accounts"
     headers = self.create_signature_headers(suffix)
     req = Request(base_url, suffix)
     rsp = req.get(headers)
     parser = Normalizer(rsp["data"])
     return parser.normalize_balances()
コード例 #11
0
 def get_symbols(cls):
     """Get symbols available"""
     endpoint = "/api/3/info"
     req = Request(base_url, endpoint)
     if req != None:
         rsl = req.get()["pairs"]
         parser = Normalizer(rsl)
         return parser.normalize_symbols()
コード例 #12
0
ファイル: okex.py プロジェクト: FliCrz/tickers-py
 def get_balances(self):
     """Get Balances from exchange"""
     suffix = "api/spot/v3/accounts",
     headers = self.create_signature_headers(suffix)
     req = Request(base_url, suffix)
     rsl = req.get()
     parser = Normalizer(rsl)
     return parser.normalize_balances()
コード例 #13
0
ファイル: p2pb2b.py プロジェクト: FliCrz/tickers-py
 def get_tickers(cls):
     """Fetch tickers from echange"""
     endpoint = "/api/v1/public/tickers"
     req = Request(base_url, endpoint)
     rsl = req.get()
     for i in rsl["result"]:
         if i != None:
             parser = Normalizer({"symbol": i, "data": rsl["result"][i]})
             yield parser.normalize_ticker()
コード例 #14
0
ファイル: idex.py プロジェクト: FliCrz/tickers-py
 def get_tickers(cls):
     """Fetch tickers from echange"""
     endpoint = "/returnTicker"
     req = Request(base_url, endpoint)
     rsl = req.get()
     for i in rsl:
         if i != None:
             parser = Normalizer({"symbol": i, "data": rsl[i]})
             yield parser.normalize_ticker()
コード例 #15
0
 def get_balances(self):
     """Get Balances from exchange"""
     suffix = "/v1/Trade/BalanceFull"
     nonce = str(int(time.time() * 1000))
     headers = self.create_signature_headers({"nonce": nonce})
     req = Request(base_url, suffix)
     rsl = req.get(headers=headers)
     parser = Normalizer(rsl)
     return parser.normalize_balances()
コード例 #16
0
 def cancel_order(self, order_id):
     suffix = "/v2/trading/cancelOrdersById"
     payload = {"ids": [order_id]}
     headers = self.create_signature_headers(suffix)
     req = Request(base_url, suffix)
     rsl = req.get()
     if order_id in rsl:
         return True
     return False
コード例 #17
0
ファイル: okex.py プロジェクト: FliCrz/tickers-py
 def get_tickers(cls):
     """Fetch tickers from echange"""
     suffix = "/api/spot/v3/instruments/ticker"
     req = Request(base_url, suffix)
     data = req.get()
     for i in data:
         parser = Normalizer(i)
         rsl =  parser.normalize_ticker()
         if not rsl == None:
             yield rsl
コード例 #18
0
 def get_tickers(cls):
     """Fetch tickers from echange"""
     suffix = "/v1/Public/Ticker"
     req = Request(base_url, suffix)
     data = req.get()
     for i in data:
         parser = Normalizer(i)
         rsl = parser.normalize_ticker()
         if not rsl == None:
             yield rsl
コード例 #19
0
ファイル: huobi.py プロジェクト: FliCrz/tickers-py
 def get_tickers(cls):
     """Fetch tickers from echange"""
     suffix_ticker = "/market/tickers"
     req = Request(base_url, suffix_ticker)
     data = req.get()["data"]
     for i in data:
         parser = Normalizer(i)
         rsl = parser.normalize_ticker()
         if not rsl == None:
             yield rsl
コード例 #20
0
 def get_tickers(cls):
     """Fetch tickers from echange"""
     suffix = "/v2/public/tickers"
     req = Request(base_url, suffix)
     data = req.get()
     if data is not None:
         for i in data:
             if not i is None:
                 parser = Normalizer(i)
                 yield parser.normalize_ticker()
コード例 #21
0
ファイル: coinex.py プロジェクト: FliCrz/tickers-py
 def get_balances(self):
     """Get Balances from exchange"""
     suffix = "/v1/balance/info?"
     nonce = str(int(time.time() * 1000))
     query_str = "access_id={}&tonce={}".format(self.key, nonce)
     headers = self.create_signature_headers(query_str)
     req = Request(base_url, suffix + query_str)
     rsl = req.get(headers=headers)
     parser = Normalizer(rsl["data"])
     return parser.normalize_balances()
コード例 #22
0
 def get_tickers(cls):
     """Fetch tickers from echange"""
     endpoint = "/api/v1/market/allTickers"
     req = Request(base_url, endpoint)
     data = req.get()
     for i in data["data"]["ticker"]:
         parser = Normalizer(i)
         rsl = parser.normalize_ticker()
         if not rsl == None:
             yield rsl
コード例 #23
0
    def get_book(cls, symbol):
        """
            Get book from exchange for symbol.

            :param symbol
                Symbol to be used for the request.
        """
        endpoint = "/api/public/v1/orderbook?market_pair={}".format(symbol)
        req = Request(base_url, endpoint)
        return req.get()
コード例 #24
0
 def get_balances(self):
     """Get Balances from exchange"""
     nonce = str(int(time.time() * 1000))
     suffix = "/api/v1.1/account/getbalances?apikey={}&nonce={}".format(
         self.key, nonce)
     headers = {"APISIGN": self.create_signature(suffix)}
     req = Request(base_url, suffix)
     rsl = req.get(headers=headers)
     parser = Normalizer(rsl["result"])
     return parser.normalize_balances()
コード例 #25
0
ファイル: btcpop.py プロジェクト: FliCrz/tickers-py
 def get_tickers(cls):
     """Fetch tickers from echange"""
     suffix = "/api/market-public.php"
     req = Request(base_url, suffix)
     data = req.get()
     if data is not None:
         for i in data:
             parser = Normalizer(i)
             rsl = parser.normalize_ticker()
             if not rsl == None:
                 yield rsl
コード例 #26
0
 def get_tickers(cls):
     """Fetch tickers from echange"""
     endpoint = "/api/v1.1/public/getmarketsummaries"
     req = Request(base_url, endpoint)
     data = req.get()
     if data is not None:
         for i in data["result"]:
             parser = Normalizer(i)
             rsl = parser.normalize_ticker()
             if not rsl == None:
                 yield rsl
コード例 #27
0
    def get_book(cls, symbol):
        """
            Get book for symbol.

            :param symbol
                Symbol to get the book from.
        """
        endpoint = "/api/3/depth/{}?limit=1".format(symbol)
        req = Request(base_url, endpoint)
        rsl = req.get()
        return rsl
コード例 #28
0
 def get_tickers(cls):
     """Fetch tickers from echange"""
     endpoint = "/api/ticker/"
     pair_list = cls.get_symbols()
     for pair in pair_list:
         req = Request(base_url, "{}{}".format(endpoint, pair))
         rsl = req.get()
         if not rsl == None:
             parser = Normalizer({"symbol": pair, "data":rsl})
             normalized =  parser.normalize_ticker()
             yield normalized
コード例 #29
0
ファイル: graviex.py プロジェクト: FliCrz/tickers-py
 def get_tickers(cls):
     """Fetch tickers from echange"""
     endpoint = "/api/v3/tickers.json"
     req = Request(base_url, endpoint)
     rsl = req.get()
     if rsl != None:
         for i in rsl:
             parser = Normalizer(rsl[i])
             parsed = parser.normalize_ticker()
             yield parsed
         pass
コード例 #30
0
ファイル: p2pb2b.py プロジェクト: FliCrz/tickers-py
 def get_balances(self):
     """Get Balances from exchange"""
     endpoint = "/api/v1/account/balances"
     body = {
         "request": endpoint,
         "nonce": str(int(time.time() * 1000))
     }
     headers = self.create_signature_headers(body)
     req = Request(base_url, endpoint)
     rsl = req.get(headers)
     rsp = requests.get(base_url + endpoint, headers=headers)
     return Normalizer(rsl["result"]).normalize_balances()