Skip to content

crypto_candles is giving data of wrong length and dates #55

Description

@AndrewBworth

Hello, I just started working with finnhub moving from yfinance. It's returning the wrong data, the data I ask for is today and up to 200 days back, but instead I get odd numbers like 128 days back or 228 days back, and the start and end times are completely wrong. Here's my "hello world", it has a unfinished function in the middle (functionmovingaverage), but it's just a rough unfinished program. I have a long list of crpytocurrencies reading out of a text file (CryptoList.txt)

#!/usr/bin/python

import finnhub
import pandas as pd
import datetime
import time

starttime = datetime.datetime.now() - datetime.timedelta(days = 200)
currenttime = datetime.datetime.now() - datetime.timedelta()
starttimestamp = int(starttime.timestamp())
currenttimestamp = int(currenttime.timestamp())

print(starttimestamp)
print(currenttimestamp)
cryptolist = open("CryptoList.txt")

fc = finnhub.Client(api_key="cjsjv99r01qm5ielfq1gcjsjv99r01qm5ielfq20")

def functionmovingaverage(pandasdata):
count = 199
sum200 = 0
sum50 = 0
sum20 = 0
sum10 = 0
sum5 = 0
lastval = 0
datalength = len(pandasdata)
print(datalength)
if datalength > 200:
print(datalength)
if datalength < 200:
return -333
for k in pandasdata.itertuples():
print(k)

for i in cryptolist.readlines():
fixedi = i.split('\n')[0]
name = fixedi
print(name)
res = fc.crypto_candles(name, 'D', starttimestamp, currenttimestamp)
dataframe = pd.DataFrame(res)
functionmovingaverage(dataframe)
time.sleep(1)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions