Ethereum: bt backtesting — > AttributeError: ‘Series’ object has no attribute ‘columns’

Canceling of cryptocurrency strategies for binance data: step by step instructions

============================================ = ============= =====================

introduction

————-

Ethereum is one of the most commonly used blockchain platforms and can be obtained from various sources. In this article, we will check how the cryptocurrency strategy using data from the popular Binance Exchange, checks and then adds the Taser library to our data framework.

Setup Seting Data

————————-

To collect Ethereum Clines from Binance, we need to submit API request. We can do this by creating a feature that returns a dictionaries list containing Clines’ data.

`Python

Import requests

Def Get_binance_klines (Symbol, Interval):

Base_url = "

paramate = {{

'Symbol': Symbol,

'Interval': Interval,

'Limit': 1000

You can customize it to your requirements

}

Answer = Request.get (Base_url, Params = Params)

If the answer.Status_code == 200:

RETURN RESPONSE.JON ()

Different:

Print (F "Failed Clines: {Answer.Stus_code}"))

return to []

This feature takes a symbol (such as ETH) and intervals (eg 1D, 5D, 15D) and returns a dictionaries containing Clines.

`Python

Clines = Get_Binance_LINES ('ETH', '1M')

Print (Clines)

Data frame creation from data

——————————-

Now we can create a panda data frame from the clines we compiled using the function pd.datataframe () .

Python

Import panda as PD

Def Convert_to_dataframe (data):

df = pd.datataframe (data, columns = ['Timestamp', 'Open', 'High', 'Low', 'Close', 'Volume'])

Turn openly and very numerically

df ['open'] = pd.to_numeric (df ['open']))

df ['high'] = pd.to_numeric (df ['high']))

Return to DF

DF = Convert_to_dataframe (Clines)

Print (DF.HEAD ())

Remove tickets from Binance

——————————

We need to make tickets from Clines. We can do this using any row of data frame and pull out the symbol of the mark.

`Python

Tickers = [line [0] line df.iloc [:, 1:]]

Print (Ticker)

Add indicators with taster

————————–

We will now use TASSER Library to add different indicators to our data framework. First of all, we need to install a TASSER library if you haven’t done so yet.

`Bash

Pip install taser

Then we can create a new column for advertising values.

`Python

Def Calcate_indicator (DF, Ticker):

This is just an example of how you can add an indicator

DF [F '{Ticker} _Upper_bounce'] = DF ['Close']. Rolling (window = 5) .Max () - DF ['Close']. Change (1)

Return to DF

DF = Calculate_indicators (DF, “Open”)

Print (DF.HEAD ())

Check the strategy

———————-

After we have a data frame with the indicator values, we can support the strategy. We will use a simple crossover strategy for changing average strategies.

“ Python

Def Backtette_Scrence (DF):

This is just an example of how you can introduce a sliding average crossover strategy

DF [‘ma’] = DF [‘Close’]. Rolling (window = 10) .Mean ()

If DF [‘MA’]. Iloc [-1]> df [‘ma’]. ILOC [-2]:

Return true

buy signal

Elif DF [‘ma’]. Iloc [-1]

Good false

sales signal

Def Backtest (DF, Strategy):

buy_signal = strategy ()

If you buy_Signal:

Print (“Buy Signal!”)

Different:

Print (“Signal Signal Stalled!”)

Now we can check our strategy in the data frame

DF [‘Strategy’] = [Backtest_ Strategy (Line) Index, line DF.iterrows ()]

Print (df.