Ethereum: Set Binance API on Raspberry Pi to Trade
As a lover of cryptocurrencies, several account management and commercial platforms can be a scary task. In this article, we go through the API Binance process at Raspberry Pi 3 B+, which allows you to store bitcoin (BTC) using Python.
Prerequisites
Before we start, check that:
- PIP and Python 3.6 or later installed in Raspberry Pi.
- You have an internet connection.
- Setting and valid for API binans.
Step 1: Install the necessary libraries
Beginners need to install the “Python-Vinance” directory using PIP:
`Bash
PIP3 Install Python-Vinance
`
This downloads the backports for various platforms, including Raspberry Pi. The .zoneinfo-5.2.1.tar.gz" package is common, which is compatible with the most installation of Python 3.
Step 2: Configure the Binance API credentials
You will then need to set up API credentials:
- Login to your Binance account.
- Go to the "Account" section and click "API Key".
3
Step 3: Create a new Python file
Create a new file calledbinance_setup.py” and add the following code:
`Python
Import sys
From the imports from the Contextlib Import
Sys.path.insert (0, ‘/usr/local/lib/pyton3.6/site-packages’)
To bring in bite
`
This imports the “Binance” directory and adds it to the Python path.
Step 4: Set API’s credentials
Change the binance_setup.py" file to incorporate your Binance API credentials:
Python
Api_key = ‘your_api_key_here’
Api_Secret = ‘Your_api_Secret_here’
Api = binance.client.create_api (‘v2’, api_key = api_key, sect = api_secret)
`
Replace your_api_key_here
i_api_secret_herewith API's actual credentials.
Step 5: Set a new stick
Create a new Python file calledbot.py” and add the following code:
`Python
Import time
from binance.client Client Imports
Def Main ():
Initialize the binance client
API = client (‘v2’, api_key = api_key, sec = api_secret)
While the truth is:
Get the latest Bitcoin price from Coingack API
Answer = api.get_price (symbol = ‘btc-isd’)
Price = Answer [‘Price’]
Set the store with Bott Logic
Print (F’Trading Stories} Btc ‘)
Time.sleep (60)
Wait 1 minute before re -election of the market
If __NAME__ == ‘__Main__’:
main()
`
This sets the basic stick that spends the latest price of Bitcoin from Cotingcko and puts it in a business when it reaches $ 100.
Step 6: Start the stick
Make a new directory called “Binance_setup” on Raspberry Pi to keep all configuration file
Config
: To store Binance API credentials
Log
: to report any error or commercial result
Copy the top code to each of these directors and definitely update the “api_keyi
api_secretspace with the actual credentials of the API.
Tips and variations
- To use another symbol (eg BTC-USD, BTCUSDT), simply update the "symbol" parameter in the Get_PRICE.
- You can add a more complex logic to your stick with conditional statements or loops. For example:
Python
If the price is> 1000: sell for $ 1000
Api.place_order (symbol = ‘btc-isd’, page = 1, type = ‘sell’)
`
- To start the stick, use the “screen” or other screen controller to maintain Raspberry PI in the background.
- Consider using designers such as “Cron” on Linux to automate the bot.
Following these steps, you should now have a basic Bincoin sales setting at Binance, Raspberry Pi 3 B+.