def sell(self, rate, amount): """ Uncertain """ nonce = myutils.nonce2() data = { "method": "trade", "currency_pair": "btc_jpy", "action": "ask", "price": rate, "amount": amount, 'nonce': nonce, "method": "trade" } signature = self._signature(data=data) #message = str(nonce) + url_path + urllib.urlencode(data) #signature = hmac.new(self.config["zaif"]["API_SECRET"], message, hashlib.sha512).hexdigest() headers = {'key': self.config["zaif"]["ACCESS_KEY"], 'sign': signature} while True: #response = requests.post(self.base_url + "tapi", headers=headers, data=data) response = myutils.post(self.base_url2, headers, data) if response.status_code == 200: ## send messege to slack myutils.post_slack(name="さやちゃん", text="Zaifで" + str(amount) + "BTCを" + str(rate) + "で売といたよ") return True
def IFD(self, amount, buy, sell): """ docstring """ nonce = myutils.nonce2() url = self.base_url url_path = "/v1/me/sendparentorder" data = { "order_method": "IFD", "minute_to_expire": self.config["bitflyer"]["minute_to_expire"], "time_in_force": "GTC", "parameters": [{ "product_code": "FX_BTC_JPY", "condition_type": "LIMIT", "side": "BUY", "price": buy, "size": amount }, { "product_code": "FX_BTC_JPY", "condition_type": "LIMIT", "side": "SELL", "price": sell, "size": amount }] } signature = self._signature(nonce=nonce, method="POST", url_path=url_path, data=data) headers = { 'ACCESS-KEY': self.config["bitflyer"]["ACCESS_KEY"], 'ACCESS-SIGN': signature, 'ACCESS-TIMESTAMP': nonce, "Content-Type": "application/json" } #response = requests.post(self.base_url + url_path, headers=headers, data=data) response = myutils.post(url=self.base_url + url_path, headers=headers, data=json.dumps(data)) if response.status_code == 200: ## send messege to slack myutils.post_slack(name="さやちゃん", text="Bitflyerで" + str(amount) + "BTCを" + str(rate) + "で買っといたよ") return True return False
def sell(self, rate, amount): """ Uncertain """ nonce = myutils.nonce() url_path = "/0/private/AddOrder" data = { 'pair': 'XXBTZJPY', 'type': 'sell', 'ordertype': 'market', 'volume:': amount } ''' data = { 'pair': 'XXBTZJPY', 'type': 'sell', 'ordertype': 'limit', 'price': rate, 'volume:': amount } ''' data["nonce"] = nonce signature = self._signature(nonce=nonce, url_path=url_path, data=data) #message = url_path + hashlib.sha256(str(nonce) + urllib.urlencode(data)).digest() #signature = hmac.new(base64.b64decode(self.config["kraken"]["API_SECRET"]), message, hashlib.sha512) headers = { 'API-Key': self.config["kraken"]["ACCESS_KEY"], 'ACCESS-SIGNATURE': signature, 'ACCESS-NONCE': nonce } #response = requests.get(self.base_url + url_path, headers=headers, data=data) response = myutils.post(self.base_url + url_path, headers, data) if response.status_code == 200: ## send messege to slack myutils.post_slack(name="さやちゃん", text="Krakenで" + str(amount) + "BTCを" + str(rate) + "で売っといたよ") return True return False
def sell(self, rate, amount): """ Uncertain """ nonce = myutils.nonce() url_path = "api/exchange/orders" ''' data = { "market_sell_amount": amount, "order_type": "market_sell", "pair": "btc_jpy" } ''' data = { "rate": rate, "amount": amount, "order_type": "sell", "pair": "btc_jpy" } signature = self._signature(nonce=nonce, url_path=url_path, data=data) #message = str(nonce) + url + data #signature = hmac.new(self.config["coincheck"]["API_SECRET"], message, hashlib.sha256).hexdigest() headers = { 'ACCESS-KEY': self.config["coincheck"]["ACCESS_KEY"], 'ACCESS-SIGNATURE': signature, 'ACCESS-NONCE': nonce } while True: #response = requests.post(self.base_url + url_path, headers=headers, data=data) response = myutils.post(self.base_url + url_path, headers, data) if response.status_code == 200: ## send messege to slack myutils.post_slack(name="さやちゃん", text="Coincheckで" + str(amount) + "BTCを" + str(rate) + "で売っといたよ") return True
def buy_fx(self, rate, amount): """ docstring """ nonce = myutils.nonce2() url = self.base_url url_path = "/v1/me/sendchildorder" data = { "product_code": "FX_BTC_JPY", "child_order_type": "LIMIT", "side": "BUY", "price": rate, "size": amount } signature = self._signature(nonce=nonce, method="POST", url_path=url_path, data=data) headers = { 'ACCESS-KEY': self.config["bitflyer"]["ACCESS_KEY"], 'ACCESS-SIGN': signature, 'ACCESS-TIMESTAMP': nonce, "Content-Type": "application/json" } #response = requests.post(self.base_url + url_path, headers=headers, data=data) response = myutils.post(url=self.base_url + url_path, headers=headers, data=json.dumps(data)) if response.status_code == 200: ## send messege to slack myutils.post_slack(name="さやちゃん", text="Bitflyerで" + str(amount) + "BTCを" + str(rate) + "で買っといたよ") return True return False