- MacOS Sierra 10.12.6
- Python 3.5.3 :: Anaconda 4.4.0 (x86_64)
- Jupyter 4.3.0
――The Zaif exchange is a valuable virtual currency exchange with virtual currencies that can be bought and sold in pairs with Japanese yen only here, such as NEM and Monacoin, as well as Bitcoin. --The Zaif exchange can make its website so heavy that it can't even log in, let alone trade, if the volume of transactions surges, such as when Bitcoin-related (mainly negative) news is reported.
--If you cannot log in to the Zaif exchange website due to overload on the server or DDoS attack, you will not be able to buy or sell virtual currency from the website.
--The Zaif exchange publishes an API that allows you to obtain trading price information and make transactions, and even if the website is heavy, the API often survives. Therefore, by using the API, you can buy and sell virtual currencies even if you cannot log in to the website. --It is necessary to buy and sell while checking the price movement at that time. See here for how to check price movements without logging in to the website: Get cryptocurrency trading price and create chart with API of Zaif exchange / items / ed9637a383b1ed49bf5f) (The chart generated by this procedure is here)
--In order to buy and sell virtual currency by API, it is necessary to obtain API key and API secret for trading in advance. This can be obtained by logging in to the Zaif exchange and going to the Account> Developer API> API keys settings screen. ** For safety reasons, it is recommended to give only the minimum required privileges to the API key ** (this time, "info" and "trade" are required). ** Also, the acquired API key and API secret must never be disclosed to others. ** **
Using ZaifAPI, simply manually buy and sell virtual currencies.
--Import zaifapi module
from zaifapi import ZaifPublicApi, ZaifTradeApi
--Buy at limit price (set limit sale)
key = "****************************" #Enter API key
secret = "****************************" #Enter API secret
zaif = ZaifTradeApi(key, secret)
price = 23 #Set the price to buy and sell (buy here for 23 yen)
amount = 1000 #Set the amount to buy and sell (buy 1000XEM here)
limit = 28 #Set a limit selling price (here, sell for 28 yen)
currency_pair = "xem_jpy" #Set a currency pair to buy and sell (here, buy NEM in Japanese Yen)
action = "bid" #Set buy or sell (buy is set here)
#Execute buying and selling
zaif.trade(currency_pair=currency_pair, action=action, price=price, amount=amount, limit=limit)
--Sell at limit price (set limit buy)
key = "****************************" #Enter API key
secret = "****************************" #Enter API secret
zaif = ZaifTradeApi(key, secret)
price = 28 #Set the price to buy and sell (here, sell for 28 yen)
amount = 1000 #Set the amount to buy and sell (here 1000XEM is sold)
limit = 23 #Set a limit selling price (buy here for 23 yen)
currency_pair = "xem_jpy" #Set a currency pair to buy and sell (here, buy NEM in Japanese Yen)
action = "ask" #Set buy or sell (set sell here)
#Execute buying and selling
zaif.trade(currency_pair=currency_pair, action=action, price=price, amount=amount, limit=limit)
――If you can buy and sell virtual currency using API, you can buy and sell even if you can not log in to the website of the exchange as long as the API is working, so you can trade without missing the time of buying and selling. can do. ** In particular, it is important to be prepared to buy and sell with the API, as the situation where the website is overloaded often occurs when the market is volatile. ** **
Recommended Posts