dursk / bitcoin-price-api Goto Github PK
View Code? Open in Web Editor NEWWrapper for various Bitcoin price API's
License: MIT License
Wrapper for various Bitcoin price API's
License: MIT License
Just noticed this error when calling CoinDesk().get_current_price() as the price is now over 1,000 USD:
decimal.InvalidOperation: Invalid literal for Decimal: u'1,004.8813'
Wrapping coindesk.py line 14 in a str().replace() as such seems to resolve.
price = data['bpi'][currency]['rate']
becomes
price = str(data['bpi'][currency]['rate']).replace(',', '')
Might have to do on the rest of the price functions as well?
New to Python and GitHub in general so didn't actually fork and try to submit a PR.
In [1]: from exchanges.bitfinex import Bitfinex
In [2]: Bitfinex().get_current_bid()
Out[2]: Decimal('9593.8')
In [4]: Bitfinex().get_current_price()
Out[4]: Decimal('9592.3')
In [5]: Bitfinex().get_current_bid()
Out[5]: Decimal('9591.1')
NameError Traceback (most recent call last)
in
----> 1 Bitfinex().get_current_ask()
/usr/local/lib/python3.7/site-packages/exchanges/base.py in get_current_ask(cls)
74
75 def get_current_ask(cls):
---> 76 self.get_data()
77 price = self._current_ask_extractor(self.data)
78 return Decimal(price)
NameError: name 'self' is not defined
Not actually an issue. Just thought I'd share. If you think its alright, please use it or your revision of it in README/example. Thanks for sharing your module, very convenient.
#!/usr/bin/python
from sys import argv
from subprocess import check_output
from exchanges.bitfinex import Bitfinex
from time import sleep
above = 11900
below = 11450
def get_price():
try:
price = int(Bitfinex().get_current_price())
except:
price = 0
return(price)
while True:
print("Checking price...")
price = get_price()
print("----------------- "+str(price))
if price > above:
tmp = check_output('notify-send "BTC price is ABOVE '+str(above)+'" -u critical -t 9999999',shell=True, universal_newlines=True)
if price < below and price != 0:
tmp = check_output('notify-send "BTC price is BELOW '+str(below)+'" -u critical -t 9999999',shell=True, universal_newlines=True)
sleep(35)
Price API:
https://bityep.com/api/1/ticker
Thanks!
If you are looking, like i was, for a decent library to easily convert crypto prices
Check this out https://github.com/coinconvert/crypto-convert/
This library seems outdated
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.