Python - Bitflyer Achat et vente de Bitcoin

Achetez et vendez des pièces de monnaie avec l'API Bitflyer

Installation de pybitflyer

pip install pybitflyer

API Key

Peut être obtenu à partir de ce qui suit après l'enregistrement https://lightning.bitflyer.jp/developer

La source

import pandas as pd
import pybitflyer
import time
from datetime import datetime

# size :Quantité commandée, prix:prix(Optionnel)
def buy(api, size, product_code = "BTC_JPY", child_order_type = "MARKET", price = None, minute_to_expire = 10000, time_in_force = "GTC"):
    if price is None:
        buy_btc = api.sendchildorder(product_code=product_code, child_order_type=child_order_type, side="BUY",size=size, minute_to_expire=minute_to_expire, time_in_force=time_in_force)
    else:
        buy_btc = api.sendchildorder(product_code=product_code, child_order_type=child_order_type, side="BUY",size=size, minute_to_expire=minute_to_expire, time_in_force=time_in_force, price=price)

# size :Quantité commandée, prix:prix(Optionnel)
def sell(api, size, product_code = "BTC_JPY", child_order_type = "MARKET", price = None, minute_to_expire = 10000, time_in_force = "GTC"):
    if price is None:
        sell_btc = api.sendchildorder(product_code=product_code, child_order_type=child_order_type, side="SELL",size=size, minute_to_expire=minute_to_expire, time_in_force=time_in_force)
    else:
        sell_btc = api.sendchildorder(product_code=product_code, child_order_type=child_order_type, side="SELL",size=size, minute_to_expire=minute_to_expire, time_in_force=time_in_force, price=price)

API_KEY = "XXXXXXXXXXXXXX"
API_SECRET = "XXXXXXXXXXXXXXXXXXXXXX"

if __name__ == '__main__':
    api = pybitflyer.API(api_key = API_KEY, api_secret = API_SECRET)
    
    # 0.Acheter 001 BTC
    buy(api=api, size=0.001)
    
    # 0.001 vente BTC
    sell(api=api, size=0.001)

Recommended Posts

Python - Bitflyer Achat et vente de Bitcoin
bibliothèque de commerce d'algorithmes python
J'ai essayé d'utiliser TradeWave (commerce du système BitCoin en Python)
Python --bitflyer Obtenir le solde des actifs
Python --bitflyer Obtenir le contenu du chat
Python
Commerce système à partir de Python3: investissement à long terme