0

I would like to pull multiple tickers from Binance and have managed to do so and write them into a CSV file. However, I am having an issue pulling specific information from the columns to have the OHLCV data only and then work on wrapping ta-lib around this data.

For eg. I would like to keep the OHLCV data from each row for XRPBTC, NEOBTC which are in columns, and write them into a new file or just wrap ta-lib around the same data. It works fine for just one ticker but I'm having some troubles extracting this for multiple tickers.

I am given to understand that these are in the format of lists, can I split them to keep only OHLCV data and from each row and from each column and write them into a new file - is there an easier way of splitting a list?

screenshot of the data

Column with lists of data in each row

Link to relevant binance documentation Klines candlestick data

import pandas as pd                                                                                                     
import numpy as np                                                                                                   
import csv   
import talib as ta                                                                                                  
from binance.client import Client                                                                                                                                                                                                                                                       
                                                                                                                                                                                                                                                                                                                                                                                 
candlesticks = ['XRPBTC','NEOBTC'] # unable to split for each row in multiple columns                                                         
data = pd.DataFrame()                                                                                                   

for candlestick in candlesticks:
    data[candlestick] = client.get_historical_klines(candlestick, Client.KLINE_INTERVAL_15MINUTE, "1 Jul, 2021")
    data.to_csv("XRPNEO15M.csv")
    print(data)                
James Z
  • 12,209
  • 10
  • 24
  • 44
  • A [mre] for your problem would be a hardcoded dataframe, your tries to get what you want from it as code, your expected output. All the other stuff of code you posted is irrelevant to the thing you want to get done. Even worse it needs a secret key that we do not have so we cannot run your code. Kindly [edit] and remove the fluff, instead add the hardcoded dataframe - see [how-to-make-good-reproducible-pandas-examples](https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples) – Patrick Artner Jul 03 '21 at 08:47
  • Also do your research: [pandas-split-column-into-multiple-columns-by-comma](https://stackoverflow.com/questions/37600711/pandas-split-column-into-multiple-columns-by-comma) – Patrick Artner Jul 03 '21 at 08:52
  • Hi, I've made the necessary edits and removed the unwanted stuff. I tried splitting my data with a comma, unfortunately it did not work – Akash Chugh Jul 03 '21 at 09:00
  • Welcome to [Stack Overflow.](https://stackoverflow.com/ "Stack Overflow"). In order for us to help you, it is necessary that you show your effort and submit data to be used to reproduce your problem. While providing an image is helpful, it doesn't allow for reproducing the issue. Please edit your question to show a minimal reproducible set. See [Minimal Reproducible Example](https://stackoverflow.com/help/minimal-reproducible-example "Minimal Reproducible Example") for details. – itprorh66 Jul 11 '21 at 16:35

0 Answers0