def test_list(): ''' list all open orders ''' o1 = order.Order(access_key=settings.access_key, secret_key=settings.secret_key) ok_(o1.list().get('success'))
def test_history(): ''' show payment history ''' o1 = order.Order(access_key=settings.access_key, secret_key=settings.secret_key) ok_(o1.history().get('success'))
def test_sell_btc_jpy(): ''' sell BTC ''' time.sleep(1) sell_value = 2 * market_info.get('bid') o1 = order.Order(access_key=settings.access_key, secret_key=settings.secret_key) ok_(o1.sell_btc_jpy(amount=0.01, rate=sell_value).get('success'))
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_cancel(): ''' cancel orders in odered in last 10 minute. ''' o1 = order.Order(access_key=settings.access_key, secret_key=settings.secret_key) order_id_list_to_be_canceled = [ x.get('id') for x in o1.list().get('orders') if get_n_min_dai(10) in x.get('created_at') ] order_id_list_to_be_canceled += [ x.get('id') for x in o1.list().get('orders') if get_n_min_dai(0) in x.get('created_at') ] if not order_id_list_to_be_canceled == []: [ ok_(o1.cancel(str(i)).get('success')) for i in order_id_list_to_be_canceled ]
def buy_market(amount_jpy): o = order.Order(secret_key=coincheck_secret_key, access_key=coincheck_access_key) return o.buy_btc_jpy_market(amount=amount_jpy, rate=0)
def history(): o = order.Order(secret_key=coincheck_secret_key, access_key=coincheck_access_key) return o.history()
import Settings from api import * from coincheck import order,market order_api = order.Order(access_key=Settings.access_token, secret_key=Settings.access_key) #order_api.create(rate=1, amount=0.01, order_type='buy', pair='btc_jpy') clear = time.time() + 5 def clear_your_mind_buddy_everything_is_going_to_be_okay(): orders = order_api.list() for order in orders['orders']: order_api.cancel(str(order['id'])) bid_id = '' ask_id = '' def loop(): global bid_id, ask_id, clear start_time = time.time() if time.time() > clear: clear_your_mind_buddy_everything_is_going_to_be_okay() clear = time.time() + 5 order_book = coincheckapi.get_orderbook(count=5) best_bid = int(float(order_book['bids'][0][0])) best_ask = int(float(order_book['asks'][0][0])) algorithim_best_bid = best_bid + Settings.increment algorithim_best_ask = best_ask - Settings.increment while algorithim_best_ask - algorithim_best_bid < Settings.minimum_yen_spread: algorithim_best_bid -= Settings.increment algorithim_best_ask += Settings.increment
# encoding: utf-8 from __future__ import print_function from coincheck import order, market, account ok = order.Order(access_key="你的accessKey", secret_key="你的secretKey") print(ok.buy_btc_jpy(amount=0.01, rate=200))
from coincheck import market, order, account from zaifapi import * import sys #APIキー認証(各取引所で自分のアカウント情報を入れておく) zaif_secret = "your access key" zaif_key = "your secret key" coincheck_key = order.Order( access_key="your access key", secret_key="your secret key" ) """売り買いする数量を決めておく""" ORDER_AMOUNT = 0.01 """zaifの板情報取得""" 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)
import re import settings ACCESS_KEY = settings.ACCESS_KEY SECRET_KEY = settings.SECRET_KEY client_email = settings.CLIENT_EMAIL private_key = settings.PRIVATE_KEY.replace('\\n', '\n') SELL_MARGIN = 2000 BUY_MARGUN = 5000 DIFFERENCE = 1000 m = market.Market() o = order.Order(access_key=ACCESS_KEY, secret_key=SECRET_KEY) a = account.Account(access_key=ACCESS_KEY, secret_key=SECRET_KEY) balance = a.get_balance() AMOUNT = round(float(balance['jpy']) / 10**7 / 2, 3) def get_market(wb): data = m.ticker() test_time = datetime.datetime.fromtimestamp(data['timestamp']) rate = int(data['last']) sheet = wb.worksheet("ticker") all_values = sheet.get_all_values() row_num = int(len(all_values)) - 1