Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancements to geohash-btc #2

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
83fbdab
Added parser to retrieve the latitude & longitude from the command line.
mibe Jul 29, 2011
79bb5cd
Added ability to use other markets than Mt. Gox.
mibe Jul 29, 2011
c683590
Consistent capitalization of help message.
mibe Jul 29, 2011
47f22d1
Use different mapping services for the map URL
mibe Jul 29, 2011
4ebc5a2
Fill latitude / longitude variables with geohash position
mibe Jul 29, 2011
c679beb
Display map service provider in help message.
mibe Jul 29, 2011
d6c0613
List available symbols at bitcoincharts
mibe Jul 30, 2011
33b6650
Bitcoin Charts switched to rolling intervals, so there is no opening …
mibe May 20, 2012
e3e05d0
Merge branch 'bcc-fix'
mibe May 20, 2012
0f4d477
Display error message if BCC has no price data for a given market
mibe May 20, 2012
fce810a
Implemented 30W Time Zone Rule
mibe May 20, 2012
8e776de
Use subparsers for argument parsing.
mibe May 26, 2012
715bfcb
Defined functions for every code part.
mibe May 27, 2012
4b2fa33
Implemented support for calculation the globalhash.
mibe May 27, 2012
10140a1
Error checking on latitude & longitude input.
mibe May 27, 2012
3721e73
List available symbols at bitcoincharts. The code got somehow lost wh…
mibe May 27, 2012
5b27910
Print latest market trade time also.
mibe May 27, 2012
cc72e08
URL of Bitcoincharts.com API updated
mibe Feb 28, 2015
6a53c22
Fixed mapping service URLs.
mibe Feb 28, 2015
a028b78
Using SSL on all URLs, except for OSM.
mibe Feb 28, 2015
0d57766
Using coinbaseUSD as default symbol.
mibe Nov 5, 2016
4049841
Update for Python 3 compatibility (tested with Python 3.8.2).
mibe Apr 11, 2020
343ac96
Using different symbol, since the old one returned old data only.
mibe Apr 11, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added ability to use other markets than Mt. Gox.
  • Loading branch information
mibe committed Jul 29, 2011
commit 79bb5cddca0bdfe45d42940ffb10a345593d97e3
20 changes: 14 additions & 6 deletions geohash.py
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
# This script is free software, licensed under the GPLv3, of which you should have received a copy with this software.
# If you didn't, I apologize, but you'll be able to find it at /usr/share/common-licences/GPL-3 or http://www.gnu.org/licenses/gpl-3.0.txt

# This script will calculate a geohash location for you based on the opening price at Mt. Gox for BTC/USD trades.
# This script will calculate a geohash location for you based on the opening price at a market for BTC trades.
# Usually, people use the DJIA for this algorithm, but I didn't think that was nerdy enough :)
# It will also automagically give you a link to a google map to the location.
# If you'd like any help with it, don't hesitate to open up an issue at github.
@@ -18,29 +18,37 @@
import urllib
import argparse

parser = argparse.ArgumentParser(description="Calculate a geohash location based on the opening price for BTC/USD trades at Mt. Gox.")
parser = argparse.ArgumentParser(description="Calculate a geohash location based on the opening price for BTC trades.")
parser.add_argument('lat', help="Latitude (integer part)", type=int)
parser.add_argument('lon', help="Longitude (integer part)", type=int)
parser.add_argument('-s', '--symbol', help="Symbol of the market (default: mtgoxUSD)", default="mtgoxUSD")

args = parser.parse_args()

latitude = args.lat
longitude = args.lon
symbol = args.symbol.lower()
jsoninfo = ""

btcinfo = urllib.urlopen("http://bitcoincharts.com/t/markets.json")
jsoninfo = btcinfo.read()
try:
btcinfo = urllib.urlopen("http://bitcoincharts.com/t/markets.json")
jsoninfo = btcinfo.read()
except IOError as (errno, strerror):
print "Could not retrieve data from bitcoincharts: " + str(strerror)
raise SystemExit

dictinfo = json.loads(jsoninfo)

todayopen = -1
for sym in dictinfo:
if sym["symbol"] == "mtgoxUSD":
if sym["symbol"].lower() == symbol:
todayopen = sym["open"]
break
else:
continue

if todayopen < 0:
raise ValueError("No data from bitcoincharts, is it down?")
raise ValueError("Symbol \"{0}\" not found. Try another one.".format(symbol))

thestring = str(datetime.date.today()) + "-" + str(todayopen)