Skip to content

Instantly share code, notes, and snippets.

@mehmetboraezer
Last active November 22, 2018 11:56
Show Gist options
  • Save mehmetboraezer/091c35d801c6bac8e913142b0e07e7e2 to your computer and use it in GitHub Desktop.
Save mehmetboraezer/091c35d801c6bac8e913142b0e07e7e2 to your computer and use it in GitHub Desktop.
Bitcoin price comparer script for coinmon and paribu
##
# Usage -> python bitcoin_calculator.py [bitcoin amount]
# Example -> python bitcoin_calculator.py 0.2123
##
import json
import os
import re
import sys
# Coinmon
coinmon_regex = re.compile('\s\d+\.\d+\s')
coinmon_result = os.popen('coinmon -c try|grep BTC').read()
coinmon_currency = float(coinmon_regex.findall(coinmon_result)[0].strip())
coinmon_total = float(sys.argv[1]) * coinmon_currency
print('__ Coinmon __')
print('Currency : {}'.format(coinmon_currency))
print('Total : {} TRY\n'.format(coinmon_total))
# Paribu
paribu_url = 'https://www.paribu.com/ticker'
paribu_result = os.popen('curl {} 2>/dev/null'.format(paribu_url)).read()
paribu_currency = json.loads(paribu_result)['BTC_TL']['last']
paribu_total = float(sys.argv[1]) * paribu_currency
print('__ Paribu __')
print('Currency : {}'.format(paribu_currency))
print('Total : {} TRY'.format(paribu_total))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment