BTC積立Bot

t2

t2

import ccxt
import math
import schedule
import time

API_KEY = 'your_api_key'
API_SECRET = 'your_api_secret'
FUND_JPY = 1000.0 # 積立額(円)

def main():

    ex = ccxt.liquid()
    ex.apiKey = API_KEY
    ex.secret = API_SECRET
    
    # 残高取得
    balance = ex.fetch_balance()
    balance_jpy = float(balance['JPY']['total'])
    
    # BTC価格取得
    ticker = ex.fetch_ticker(symbol='BTC/JPY')
    btc_price = float(ticker['ask'])

    # 購入量計算(Liquidは最低取引量0.0001)
    amount = math.floor((FUND_JPY / btc_price) * 10 ** 4) / (10 ** 4)
    
    # 成行で購入
    try:
        order = ex.create_market_buy_order(symbol='BTC/JPY', amount=amount)
    except Exception as e:
       print(e)
    else:
       print(order)

# 積立スケジュール (https://schedule.readthedocs.io/en/stable/ )
schedule.every().day.at("10:00").do(main)

while True:
    schedule.run_pending()
    time.sleep(1)

あなたも記事の投稿・販売を
始めてみませんか?

Tipsなら簡単に記事を販売できます!
登録無料で始められます!

Tipsなら、無料ですぐに記事の販売をはじめることができます Tipsの詳細はこちら
 

この記事のライター

t2

このライターが書いた他の記事

  • 【STEPN】アセット管理自動化ツール作成チュートリアル

    ¥1,000
    1 %獲得
    (10 円相当)
  • Googleスプレッドシートに相場価格を自動取得する方法

関連のおすすめ記事

  • 『日本株入門の決定版』- 低位株大全 - 

    ¥34,980
    1 %獲得
    (349 円相当)
    諏訪|日本株研究家

    諏訪|日本株研究家

  • 仮想通貨の短期トレード講座【30日で50万円の利益作る投資手法】

    ¥2,980
    1 %獲得
    (29 円相当)
    Genki|海外仮想通貨の先生

    Genki|海外仮想通貨の先生

  • ローソク足の哲学~How to Beat Binary Options~

    ¥30,000
    1 %獲得
    (300 円相当)
    Profilingk

    Profilingk