def main(): # ビットコインの最新取引履歴を取得 ma = market.Market() data = ma.trades() # データを表示 for e in data: for key, value in e.items(): print(key,':', value) print('--------------')
from pprint import pprint from coincheck import market import time import matplotlib.pyplot as plt asks = [] m1 = market.Market() i = 0 while True: res = m1.ticker() pprint(res) asks.append(res['ask']) if i > 10: break i += 1 time.sleep(1) plt.plot(asks) plt.show()
return distance # Initialize api clients sql_client = sqlite3.connect('depth.db') cur = sql_client.cursor() cur.execute('''CREATE TABLE IF NOT EXISTS depth (timestamp real, bf_ask_1 real, bf_bid_1 real, cc_ask_1 real, cc_bid_1 real, liquid_ask_1 real, liquid_bid_1 real, bf_ask_10 real, bf_bid_10 real, cc_ask_10 real, cc_bid_10 real, liquid_ask_10 real, liquid_bid_10 real, bf_ask_50 real, bf_bid_50 real, cc_ask_50 real, cc_bid_50 real, liquid_ask_50 real, liquid_bid_50 real, bf_ask_100 real, bf_bid_100 real, cc_ask_100 real, cc_bid_100 real, liquid_ask_100 real, liquid_bid_100 real, bf_ask_300 real, bf_bid_300 real, cc_ask_300 real, cc_bid_300 real, liquid_ask_300 real, liquid_bid_300 real, bf_ask_500 real, bf_bid_500 real, cc_ask_500 real, cc_bid_500 real, liquid_ask_500 real, liquid_bid_500 real, bf_ask_1000 real, bf_bid_1000 real, cc_ask_1000 real, cc_bid_1000 real, liquid_ask_1000 real, liquid_bid_1000 real);''' ) cc_client = market.Market() bf_client = pybitflyer.API() liquid_client = pyliquid.API() # get board of each exchange bf_board = bf_client.board() cc_board = cc_client.orderbooks( ) # you can only get 200 orders from best using cc REST api liquid_board = liquid_client.get_orderbook(id=5) def save_task(): while True: ts = time() bf_board = bf_client.board() cc_board = cc_client.orderbooks() liquid_board = liquid_client.get_orderbook(id=5)
from coincheck import order, market import settings from nose.tools import * import os, sys import time market_info = market.Market().ticker() def get_n_min_dai(minute=0, tz='UTC'): ''' return :minute: before time. ''' from datetime import datetime, timedelta from pytz import timezone return (datetime.now(timezone(tz)) - timedelta(minutes=minute)).strftime('%Y-%m-%dT%H:%M')[:-1] def test_buy_btc_jpy(): ''' buy BTC ''' time.sleep(1) buy_value = market_info.get('ask') / 2 o1 = order.Order(access_key=settings.access_key, secret_key=settings.secret_key) ok_(o1.buy_btc_jpy(amount=0.01, rate=buy_value).get('success')) def test_sell_btc_jpy():
def __init__(self, event_queue, api_key=None, api_secret=None): self.event_queue = event_queue self.api = market.Market() self.dt_format = "%Y-%m-%d %H:%M:%S"
#!/usr/bin/python #-*- codong: utf-8 -*- import requests import json from coincheck import market, order from sender import Line ma = market.Market() URL = "https://coincheck.com/api/rate/" #coins = {"XEM": "xem_jpy", "XRP": "xrp_jpy"} #multi coins = {"BTC": "btc_jpy"} #sigle if __name__ == '__main__': message = "" for key, item in coins.items(): #get coincheck's rate coincheck = requests.get(URL + item).json() #inform line Line().sender(key + " is " + coincheck["rate"] + " jpy") #process only for specific coin if key == "XRP": if (float(coincheck.item) > 200.0): Line().sender("XRP over 155 yen" + coincheck["rate"])
zaif = ZaifPublicApi() zaifP = ZaifTradeApi(zaif_key, zaif_secret) #トレードしたい通貨 pair = "btc_jpy" #板情報の取得 zaif_board_data = zaif.depth(pair) zaif_ask_price= zaif_board_data['asks'][0][0] zaif_bid_price = zaif_board_data['bids'][0][0] #print(zaif_board_data) #print("AskPrice:",zaif_ask_price,"BidPrice:",zaif_bid_price) """coincheckの板情報取得""" m = market.Market() ticker = m.ticker() coincheck_ask_price = ticker["ask"] coincheck_bid_price = ticker["bid"] #print(coincheck_bid_price, coincheck_ask_price) """買値、売値の比較""" #買値を比較 if (coincheck_bid_price < zaif_bid_price): bid_max = zaif_bid_price bid_max_code = 'zaif' if (coincheck_bid_price >= zaif_bid_price): bid_max = coincheck_bid_price