<jupyter_start><jupyter_text>Set-up<jupyter_code># API keys
publickey='<KEY>'
secret='<KEY>'
# Import dependencies

from binance import Client, ThreadedWebsocketManager, ThreadedDepthCacheManager
import pandas as pd<jupyter_output><empty_output><jupyter_text>Authentication<jupyter_code>client= Client(publickey,secret)<jupyter_output><empty_output><jupyter_text>Get Tickers<jupyter_code>tickers=client.get_all_tickers()
tickers
tickers[0]
tickers[0]['symbol']
data=pd.DataFrame(tickers)
data.head()
data.tail()
data.set_index('symbol',inplace=True)
data.head()
float(data.loc['ETHBTC'])
data.loc['ETHBTC']<jupyter_output><empty_output><jupyter_text>Get Depth of the market<jupyter_code>depth=client.get_order_book(symbol='ETHBTC')
depth
depth_data=pd.DataFrame(depth['asks'])
depth_data.columns=['Price', 'Volume']
depth_data.head()<jupyter_output><empty_output><jupyter_text>Get Historic Data<jupyter_code>historical=client.get_historical_klines('ETHBTC',Client.KLINE_INTERVAL_1DAY,'1 Jan 2015')
historical_df=pd.DataFrame(historical)
historical_df.head()
ColumnNames= ['Open Time','Open','High','Low','Close','Volume','Close Time','Quote Asset Volume',
              'Number of Trades','Taker Buy Base Asset Volume',
            'Taker Buy Quote Asset Volume','Ignore']
historical_df.columns=ColumnNames
historical_df.head()
historical_df.shape
historical_df.dtypes<jupyter_output><empty_output><jupyter_text>Pre-process historical klines data<jupyter_code># Change times to date-time format
historical_df['Open Time']=pd.to_datetime(historical_df['Open Time']/1000,unit='s')
historical_df['Close Time']=pd.to_datetime(historical_df['Close Time']/1000,unit='s')
historical_df.dtypes
# Strings to int
num_cols=['Open','High','Low','Close','Volume','Quote Asset Volume','Number of Trades','Taker Buy Base Asset Volume','Taker Buy Quote Asset Volume','Ignore']
historical_df[num_cols]=historical_df[num_cols].apply(pd.to_numeric,axis=1)

historical_df.dtypes
historical_df.describe()
historical_df.info()<jupyter_output><class 'pandas.core.frame.DataFrame'>
RangeIndex: 1519 entries, 0 to 1518
Data columns (total 12 columns):
 #   Column                        Non-Null Count  Dtype         
---  ------                        --------------  -----         
 0   Open Time                     1519 non-null   datetime64[ns]
 1   Open                          1519 non-null   float64       
 2   High                          1519 non-null   float64       
 3   Low                           1519 non-null   float64       
 4   Close                         1519 non-null   float64       
 5   Volume                        1519 non-null   float64       
 6   Close Time                    1519 non-null   datetime64[ns]
 7   Quote Asset Volume            1519 non-null   float64       
 8   Number of Trades              1519 non-null   float64       
 9   Taker Buy Base Asset Volume   1519 non-null   float64       
 10  Taker Buy Quote Asset Volume  1519 non-null   float64       
 11  Ignore                        [...]<jupyter_text>Visualisation<jupyter_code># Import MPLfinance
import mplfinance as mpf
mpf.plot(historical_df.set_index('Close Time').tail(50))
mpf.plot(historical_df.set_index('Close Time').tail(50),
        type='candle',style='charles',
        title='ETHBTC last 50 days')
# Add Volume Data
mpf.plot(historical_df.set_index('Close Time').tail(50),
        type='candle',style='charles',
        volume=True,
        title='ETHBTC last 50 days')
mpf.plot(historical_df.set_index('Close Time').tail(50),
        type='candle',style='charles',
        volume=True,
        title='ETHBTC last 50 days',
        mav=(10,20))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12265433777536035, 'fraction_numerical': 0.03426706554256187, 'mean_word_length': 3.4635922330097086, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '548381', 'license': 'MIT', 'n_tokens_mistral': 1302, 'n_tokens_neox': 1177, 'n_words': 224, 'path': 'eda-notebook.ipynb', 'repo_name': 'iannjari/binance-EDA', 'size': '3795'}