Giter VIP home page Giter VIP logo

cryptocompare's People

Contributors

deepsourcebot avatar dependabot[bot] avatar duppie4000 avatar gilir4t1qbit avatar lagerfeuer avatar lpx55 avatar lshahar avatar mohataher avatar patrickalphac avatar xavierxiexin avatar yirujeon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cryptocompare's Issues

Way to check cryptocompare limit was exceeded

If cryptocompare is queried too frequently I get the error message:
"[ERROR] You are over your rate limit please upgrade your account!"

Using get_historical_price_hour it will then return None. However I like to know itΕ› because of the limitation and not e.g. coin is not supported. I do I do that?

Add a Release workflow

Add a workflow that will automatically upload the package to pypi if it is pushed with a version tag vX.X.X.

Add get_pairs()

Add get_pairs() to module, to tests, and to README. Gets all pairs for an exchange, if passed, or all pairs for all exchanges otherwise.

pip installation error

An error occurs when install the package by pip

$ pip install cryptocompare

Collecting cryptocompare
Using cached cryptocompare-0.3.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "", line 1, in
File "/private/var/folders/hc/jf7tmyyn3fq_8d7l7m_fm09c0000gn/T/pip-build-s3mE1w/cryptocompare/setup.py", line 3, in
with open('README.rst', encoding="utf-8") as f:
TypeError: 'encoding' is an invalid keyword argument for this function

Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/hc/jf7tmyyn3fq_8d7l7m_fm09c0000gn/T/pip-build-s3mE1w/cryptocompare/

get_historical_price with list of coins

I would like to know the historical value of coins from yesterday:

import cryptocompare
from datetime import datetime, timedelta
yesterday = datetime.now() - timedelta(1)

coin_list = ['BTC', 'XRP']
print(cryptocompare.get_historical_price(coin_list, 'EUR', yesterday))

I get the error:

[ERROR] There is no data for the symbol ['BTC', 'XRP'] .

Which forces me to request one coin at the time, which is quite slow..

Proxy Support ?

Does cryptocompare supports proxy ? If yes How Could I redirect it's traffic via a proxy ?

Hourly Data Support?

Hey guys, just wanted to say that I really appreciate the work. Glad someone was able to get the API working in Python. Was wondering if you would be able to add in an API function for hourly historical data? Its already a function provided by Cryptocompare (HistoHour). Thanks.

get_average does not work

get_avg (generateAvg on CryptoCompare) does not work anymore, not even the examples provided by CryptoCompare. They exit with error: "e param seems to be missing."

Error getting coin information

The function cryptocompare.get_coin_list(format=False) is returning no response,
the response is :
Error getting coin information. Expecting value: line 1 column 1 (char 0)
was working totally fine till yesterday but started getting error today.
ss

Getting all data for a coin

Hi,
I was wondering if there is a way to set the limit in historical data to ALL or MAX.
eg:
data = get_historical_price_minute('BTC', 'EUR', limit=ALL/MAX, exchange='CCCAGG', toTs=datetime.datetime.now())

I currently get "limit is larger than max value" when I use a large number for the limit.

Thanks.

Incorrect historical data

Calling: cryptocompare.get_historical_price_day('ETH') seems to have price errors compared with the REST api.

library returns most recent as:

{'time': 1675814400,
 'high': 1580.22,
 'low': 1552.67,
 'open': 1557.99,
 'volumefrom': 12791.86,
 'volumeto': 19984578.54,
 'close': 1561.35,
 'conversionType': 'direct',
 'conversionSymbol': ''}

https://min-api.cryptocompare.com/data/v2/histoday?fsym=ETH&tsym=USD&limit=10 - return

time: 1674950400
high: 1658.36
low: 1566.99
open: 1572.46
volumefrom: 502089.89
volumeto: 812096302.45
close: 1645.46
conversionType: "direct"
conversionSymbol: ""

Returning wrong historical data during runtime app

I encountered recently issue with getting historical data during runtime app, for example Pyqt5 or even
running it on jupyter notebook. Here is example data:

Time now: 2023-06-13 12:07:23.156518
Time of data: 2023-06-13 02:09:00

{'time': 1686614940,
 'high': 25901.76,
 'low': 25894.92,
 'open': 25895.07,
 'volumefrom': 4.707,
 'volumeto': 121916.59,
 'close': 25901.42,
 'conversionType': 'direct',
 'conversionSymbol': ''}

The reason of that difference of time is because i ran kernel at night.

It always returns the data from the time kernel was started, so to get the real time data i would have to restart the kernel.
The same thing happens when using application in Pyqt5. However using cryptocompare.get_price(...) it always returns the newest value. Somewhere i read that it could be caching mechanism implemented in the library I am not sure if it was meant to be like this. Is there any solution to overcome this problem? Maybe it's only at my side and just can't address the issue.

History of data between two dates

Hi,

I would like advice to build the same function but to get all history of data (Close, dates, volume) between two dates :)

And for all tradable pairs

Could you please help me ? thanks

def get_historical_price(coin, curr=CURR, timestamp=time.time()):
if isinstance(timestamp, datetime.datetime):
timestamp = time.mktime(timestamp.timetuple())
return query_cryptocompare(URL_HIST_PRICE.format(coin, format_parameter(curr), int(timestamp)))

How to just get the current price?

coin_price = (cryptocompare.get_price(coin,curr='USD',full=False))
dictlist = list(coin_price.values())
print(dictlist[0])

This gives us "{'USD': 0.06061}". Is it possible to just get the numerical value (0.06061) instead of getting the whole string "{'USD': 0.06061}"? This would be useful in further computations

Rewrite query functions to use **kwargs

All query functions shall use **kwargs as the single argument, removing the need to specify each field separately and allowing users to pass all supported arguments by the API.

Calling from Windows WSL Ubuntu strips out response info from JSON

To do some testing on my local windows machine I want to update a SQLite database with an API call to Cryptocompare. However, I get different JSON back in Ubuntu (WSL) than I get back in Windows. Weird! This becomes a problem later when I parse the JSON into SQLite. To make matters even stranger, this works fine on my Ubuntu VM instance on Google Cloud.

In Ubuntu in Windows WS I run this and get this:
res = cryptocompare.get_historical_price_minute('BTC', curr='USD',limit=1) print(res)
[{'time': 1580058960, 'close': 8561, 'high': 8569.55, 'low': 8561, 'open': 8565.61, 'volumefrom': 35.27, 'volumeto': 302097.78}, {'time': 1580059020, 'close': 8554.96, 'high': 8561, 'low': 8554.96, 'open': 8561, 'volumefrom': 0, 'volumeto': 0}]

Under Windows Python I get this:
res = cryptocompare.get_historical_price_minute('BTC', curr='USD',limit=1)

print(res)
{'Response': 'Success', 'Type': 100, 'Aggregated': False, 'Data': [{'time': 1580059800, 'close': 8564.72, 'high': 8565.85, 'low': 8561.4, 'open': 8561.4, 'volumefrom': 9.249, 'volumeto': 79165.7}, {'time': 1580059860, 'close': 8564.51, 'high': 8564.72, 'low': 8564.51, 'open': 8564.72, 'volumefrom': 0, 'volumeto': 0}], 'TimeTo': 1580059860, 'TimeFrom': 1580059800, 'FirstValueInArray': True, 'ConversionType': {'type': 'direct', 'conversionSymbol': ''}, 'RateLimit': {}, 'HasWarning': False}

can not get coin lidz

Hi,
suddenly i cant retrieve coin info no more. It throws this error:

Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "..\cryptocompare.py", line 52, in get_coin_list
    response = query_cryptocompare(URL_COIN_LIST, False)['Data']
TypeError: 'NoneType' object is not subscriptable
Error getting coin information. Expecting value: line 1 column 1 (char 0)

I am new to coding, so i dont know if thats really an issue of crypto compare, but i tried in a fresh console and i got same error. Maybe could some look into it.

Get The number of cryptos label:enhancement

now i need to do this: Pull out a request for all the coins on the list then print it's length

list=cryptocompare.get_coin_list(format=True)
print(len(list))

i wont something lees invasive like: Guste pool out the length

Number=cryptocompare.get_coin_list_number()
print(Number)

PS: if there is all ready a way i'm sorry

Premature termination when fetching price history

I think I found a bug that occurs in get_historical_price_hour_from (and I think in get_historical_price_day_from as well, but I only used get_historical_price_hour_from so I will be talking about this function).

So basically if I understand your code correctly, you keep fetching the price history until we are at fromTs, but basically if price history is not available (because we go beyond the time where price history is stored) it returns only zeroes: {'time': xxxxxxx, 'high': 0, 'low': 0, 'open': 0, 'volumefrom': 0, 'volumeto': 0, 'close': 0, 'conversionType': 'direct', 'conversionSymbol': ''} and you remove those from the list in validHist = [elem for elem in p if elem["time"] >= fromTs_i and elem["open"] != 0 and elem["close"] != 0]. So for example I would get this response if I try to get the price history of Ethereum on January 1st 2000. I would get only zeroes because Ethereum didn't exist back then.

And I think you also assumed that. Because a few lines later at if len(validHist) < len(p): break, you check if we removed some zero entries (and elem["time"] >= fromTs_i but that is not important for this story) and if we did, you assume that we reached the end of valid price histories and we break out of the while loop. However, when fetching the price history of Solana (but it applies to other coins as well), I got this:

bug

For whatever reason, the price history sometimes has zero entries in it, even though we haven't reached the end yet! In my example, I was fetching from January 1st 2010 (just a lower bound to indicate that I want all the possible price history available) until July 1st 2023. But it prematurely terminated in this loop, even though there is more price history to fetch!

A possible fix could be to not terminate when we removed at least 1 entry, but to keep going until all 2000 (or to how much limit is set) entries are zero entries. In that case you are absolutely sure that you reached the very beginning of a coin's price history.

Constantly getting an error You are over your rate limit please upgrade your account!

Hi,

  1. I have installed latest version of cryptocompare via pip.
  2. I have registered and created an API key at cryptocompare (checked the following options)
    image
  3. I have tested freshly created API key @ cryptocompare website, getting response without problems.
  4. I placed API key to .env file
  5. In my jupyter notebook, I tried the following:
import cryptocompare as cr
from dotenv import load_dotenv # add this line for api key loading
import os
load_dotenv()
apikey=os.getenv('API_KEY')
(api key loaded successfully, the same as created).
# setting the key for cryptocompare library
cr.cryptocompare._set_api_key_parameter(apikey)
# response is ok, '&api_key=xxx(my api key here)'

but, when I am trying:
btc=cr.get_historical_price_day('BTC', currency='USD', limit=30)

I constantly get an error that I am over my rate limit.

Can you please direct me what I am doing wrong?

Can you please explain variable limit in method get_historical_price_day

As title.

In following crptocompare API example, the variable limit works with aggregation number. However I don't find aggregation in your code.

The number of data points to return. If limit * aggregate > 2000 we reduce the limit param on our side. So a limit of 1000 and an aggerate of 4 would only return 2000 (max points) / 4 (aggregation size) = 500 total points + current one so 501. [ Min - 1] [ Max - 2000] [ Default - 168]

Can you explain how to understand variable limit? For example, if the return data points is 10 for a specific time, what does it mean?

Thank you!

Clean up requirements.txt

requirements.txt is a mess right now, I accidentally exported my entire venv folder. Clean it up and therefore remove the noise.

Getting price as string

Hi,
I was wondering if it is possible to get the price and print of a coin as a string.

BTC = cryptocompare.get_price(currency='usd', coin='btc')
then
print(BTC)

This prints as a Python dictionary. What I want is to print only the price as text. I tried to measure the problem as a nested dictionary but I couldn't succeed.

Thanks already.

SOLUTION: Actually I found an issue on my code, print(BTC['BTC']['USD']) basically this gives only the price.

Document the source code

Document the source code so that code completion will show doc strings when using cryptocompare.

Passing API keys

Is there a way to pass CryptoCompare API keys to pull down more data?

NameError: name 'TICKER' is not defined

I keep getting this error:

NameError: name 'TICKER' is not defined

When I run:

from cryptofeed import FeedHandler

fh = FeedHandler()

# ticker, trade, and book are user defined functions that
# will be called when ticker, trade and book updates are received
ticker_cb = {TICKER: TickerCallback(ticker)}
trade_cb = {TRADES: TradeCallback(trade)}
gemini_cb = {TRADES: TradeCallback(trade), L2_BOOK: BookCallback(book)}


fh.add_feed(Coinbase(pairs=['BTC-USD'], channels=[TICKER], callbacks=ticker_cb))
fh.add_feed(Bitfinex(pairs=['BTC-USD'], channels=[TICKER], callbacks=ticker_cb))
fh.add_feed(Poloniex(pairs=['BTC-USDT'], channels=[TRADES], callbacks=trade_cb))
fh.add_feed(Gemini(pairs=['BTC-USD', 'ETH-USD'], channels=[TRADES, L2_BOOK], callbacks=gemini_cb))

fh.run()

Add exchange to get_historical_price (minute, hour, and day)

In the cryptocompare API, it's possible to pass the exchange via the e argument to get_historical_price_minute (hour and day), but not currently through this package. This addition needs to be made to each of those three functions, to the tests, and to the README.

I've made the (pretty straightforward) changes in this Pull Request: #32

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.