Ethereum: Historic market data from Bitfinex

Data on the Bitfinex Ethereum historic market: a step by step guide

As an Ethereum developer, you probably know the importance of having precise and reliable historical market data to enlighten your trading strategies. In this article, we will explain how to recover historical data from the OHLC (open, high, low, closed) of the Bitfinex API using a step by step guide.

Prerequisite

Before diving into the code, make sure you have:

  • A bitcoin account on Coinbase or another exchange

  • API identification information necessary for your cryptocurrency portfolio provider (for example, Bitpay, Binance)

3.

Step 1: Configure your Bitfinex API identification information

Connect to your Bitfinex account and access the “API” section. Create a new application or change an existing, then click “Create a new API customer”. Copy the customer ID and the customer’s secret, because you will need it later.

Step 2: Choose the symbol of cryptocurrency

Select the Ethereum (ETH) cryptocurrency in your Bitfinex account. You can find it in the list of symbols available in the “Symbols” section.

Step 3: Create a new request to recover historic OHLC data

Use the following code as an example:

`Python

Import requests

Define API identification information

customer_id = 'your_client_id'

client_secret = 'your_client_secret'

Define the cryptocurrency symbol and time beach

symbol = 'eth'

Start_Time = '2020-01-01 00:00:00'

end_time = '2022-02-26 23:59:59'

Build the API request URL

URL = F'HTTPS: //API.BITFINEX.COM/V5/SYMBOLS/ {Symbol}/OHLC? start = {start_time} & end = {end_time} '

Define API headers (optional)

headers = {

"Standard content": "application / json",

'x-bitfinex-dep-ky': customer_secret

}

Send the request to recover historic data OHLC

Response = Requires.get (URL, headers = headers)

Check if the answer has succeeded

If response.status_code == 200:

Analyze the JSON response and store data in a list

Data = answer.json ()

For the element in the data ["data"]:

Print (article ['date'], element ['open'], element ['high'], element ['Low'], element ['close'])

other:

print (f'error: {answer.status_code} ')

'

Step 4: Manage pagination and analyze the JSON response

If your request returns a paginated response, you will have to manage it accordingly. In this example, we use the variableData 'as an OHLC data list.

To analyze the JSON response and store data in a more practical format (for example, a dataframe pandas), you can use libraries like "pandas". Here is an updated code extract:

Python

Import pandas as a PD

Define a function to analyze the JSON answer and create a dataframe pandas

DEF PARSE_OHLC_DATA (data):

Create a dictionary with OHLC data

df = data [0] .To_dict ()

Create a dataframe pandas from the dictionary

df ['date'] = [item ['date'] for the element in df]

df ['open'] = [item ['open'] for the element in df]

DF ['High'] = [item ['High'] for the element in DF]

DF ['Low'] = [Item ['Low'] for the element in DF]

df ['close'] = [item ['close'] for the element in DF]

Return pd.dataframe (DF)

Analyze the JSON answer and create a dataframe pandas

DF = PARSE_OHLC_DATA (data)

` ‘

Step 5: Print or use your data

Now that you have recovered the historic data from the OHLC, you can print it on the console or store it in a database for more in -depth analysis.

That’s it! You have managed to recover and analyze data from the Ethereum de Bitfinex historic market using the Bitfinex API. Do not forget to keep your identification information secure API and manage the pagination accordingly when recovering large sets of data. Happy coding!