GregoryMorse / trendln

Support and Resistance Trend lines Calculator for Financial Analysis
MIT License
663 stars 162 forks source link

Change OHLC to yfinance format #15

Open gambitov opened 4 years ago

gambitov commented 4 years ago

Dear developer, thank you for sharing your code, It is very impressive.

I want to use it in cryptocurrencies, so I have an issue trying to change my Pandas format (Dataframe) with OHLC to the format required in yfinance.

I have replazed

tick = yf.Ticker('^GSPC') # S&P500
hist = tick.history(period="max", rounding=True)
h = hist[-1000:].Close

for

candles = exchange.fetch_ohlcv ('BTC/USDT', '4h')
df = pd.DataFrame(candles,columns=['Date','Open','High','Low','Close','Volume'])
df['Date'] = df['Date'].apply(lambda date: pd.Timestamp(time.ctime(date/1000.)))
h = df['Close']
hist = df

It is working, but I do not know if I done correctly, what do you think?