API Bitrex with Python!!! Balance!!!
Making my system in ODOO form to extract and manipulate information from the main APIs with python, in this case we have Bittrex to start !!!
Why Bittrex?
Simple Bittrex is where I have about 60 Dollars invested in different currencies, the idea that came to mind was to actually make 2 systems, 1 for general information with information of all crypto-coins and a 2nd stage or 2nd system with The information of my account in ODOO, but more or less that consist, I proceed to portray the 2nd, and the 1st or 1st stage I have portrayed but for a next entry may take more in depth and show some examples of what already does....
System Management of my APIs .. In this case Bittrex
Well I've done a lot of laps and I have more than 60 dollars in Bittrex invested, I've actually invested only 40 or less and everything else is profit !!!
It is interesting to know how much the coins go up and down for every hour, day, week or month and even year, but more interesting has seemed to me to see how much they gain or lose MY COINS, MY INVESTMENT from time to time ... So I decided to connect to The Bittrex API and create a program in ODOO to please my curiosity, but I realized that it can serve as a basis to sell when you are not interested in losing more or when you can earn more than you expected.
For example, I invested 5 $ in STEEM when I climbed a day 5%, no problem, when I went down 3% there was no problem, it went up 10% no problem but one day it went up 40% so my program should sell, here we are not using ranges Limits if not% profit ranges for days or hours, this is the interesting thing that I can shape the system to what I want !! Even if it drops a lot 1 day no matter how much I have won I want to sell without being in the computer, according to the market price of the moment, and here I bring the first part of the program:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from bittrex import Bittrex
APIKEY = "AQUI TU API KEY"
SECRETKEY = "AQUI TU API SECRETKEY"
bittrex = Bittrex("APIKEY", "SECRETKEY")
steem_bittrex = bittrex.get_ticker('BTC-STEEM')
print steem_bittrex
The exit of the Program is simply the current market value BTC-STEEM:
{u'message': u'', u'result': {u'Ask': 0.00018007, u'Bid': 0.000178, u'Last': 0.00018007}, u'success': True}
For example Ask is when you are Selling and Bid as soon as you buy, we can run a code and see what is the difference between what is paid and sold, in this case we simply subtract 0.00018007-0.000178 to give an example , So we will use this information to know if we should or want to sell or buy according to% of the variances of our money ...
For example to extract all the data of your account here I have this code, in which you must also place the api_key and the secret_key:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from bittrex import Bittrex
APIKEY = "AQUI TU API KEY"
SECRETKEY = "AQUI TU API SECRETKEY"
bittrex = Bittrex("APIKEY", "SECRETKEY")
get_balances = bittrex.get_balances
print get_balances()
With this code we will get a compound dictionary in which we will have our currencies like this:
{u'message': u'', u'result': [{u'Available': 0.0, u'Currency': u'ARDR', u'Balance': 0.0, u'Pending': 0.0, u'CryptoAddress': None}, {u'Available': 48.62931742, u'Currency': u'ARK', u'Balance': 48.62931742, u'Pending': 0.0, u'CryptoAddress': None}, {u'Available': 0.0, u'Currency': u'BAY', u'Balance': 0.0, u'Pending': 0.0, u'CryptoAddress': None}, {u'Available': 0.0, u'Currency': u'BSD', u'Balance': 0.0, u'Pending': 0.0, u'CryptoAddress': None}, {u'Available': 0.0, u'Currency': u'BTC', u'Balance': 0.0, u'Pending': 0.0, u'CryptoAddress': u'1P51unY2adHe6M5Db2sv8GMqqwQ9JZZ9F'}, {u'Available': 500.0, u'Currency': u'BTS', u'Balance': 500.0, u'Pending': 0.0, u'CryptoAddress': None}, {u'Available': 2000.0, u'Currency': u'BURST', u'Balance': 2000.0, u'Pending': 0.0, u'CryptoAddress': None}, {u'Available': 0.0, u'Currency': u'CANN', u'Balance': 0.0, u'Pending': 0.0, u'CryptoAddress': None}, {u'Available': 5000.0, u'Currency': u'DGB', u'Balance': 5000.0, u'Pending': 0.0, u'CryptoAddress': None}, {u'Available': 0.0, u'Currency': u'DOGE', u'Balance': 0.0, u'Pending': 0.0, u'CryptoAddress': None}, {u'Available': 200.0, u'Currency': u'EBST', u'Balance': 200.0, u'Pending': 0.0, u'CryptoAddress': None}, {u'Available': 0.0, u'Currency': u'ETH', u'Balance': 0.0, u'Pending': 0.0, u'CryptoAddress': u'0xfceb60a84b55a52d2d873071028175c3d5fa0782'}, {u'Available': 1649.20421452, u'Currency': u'FC2', u'Balance': 1649.20421452, u'Pending': 0.0, u'CryptoAddress': None}, {u'Available': 1000.20954327, u'Currency': u'FLDC', u'Balance': 1000.20954327, u'Pending': 0.0, u'CryptoAddress': None}, {u'Available': 201.12880227, u'Currency': u'GOLOS', u'Balance': 201.12880227, u'Pending': 0.0, u'CryptoAddress': None}, {u'Available': 100.0, u'Currency': u'LMC', u'Balance': 100.0, u'Pending': 0.0, u'CryptoAddress': None}, {u'Available': 50.0, u'Currency': u'MUE', u'Balance': 50.0, u'Pending': 0.0, u'CryptoAddress': None}, {u'Available': 1791.7287752, u'Currency': u'MZC', u'Balance': 1791.7287752, u'Pending': 0.0, u'CryptoAddress': None}, {u'Available': 100.0, u'Currency': u'NLG', u'Balance': 100.0, u'Pending': 0.0, u'CryptoAddress': None}, {u'Available': 100.0, u'Currency': u'NXT', u'Balance': 100.0, u'Pending': 0.0, u'CryptoAddress': None}, {u'Available': 100.0, u'Currency': u'SLING', u'Balance': 100.0, u'Pending': 0.0, u'CryptoAddress': None}, {u'Available': 0.0, u'Currency': u'STEEM', u'Balance': 0.0, u'Pending': 0.0, u'CryptoAddress': u'f5130c64b54c4dd399c'}, {u'Available': 0.0, u'Currency': u'VOX', u'Balance': 0.0, u'Pending': 0.0, u'CryptoAddress': None}, {u'Available': 1000.0, u'Currency': u'XLM', u'Balance': 1000.0, u'Pending': 0.0, u'CryptoAddress': None}, {u'Available': 100.0, u'Currency': u'XRP', u'Balance': 100.0, u'Pending': 0.0, u'CryptoAddress': None}, {u'Available': 0.0, u'Currency': u'ZCL', u'Balance': 0.0, u'Pending': 0.0, u'CryptoAddress': None}], u'success': True}
For the next entry step to format to add the coins in BTC and take a control with python par later to create a module in ODOO that carries only this information, I find more interesting than the previous system and I will share it: D
May God bless and keep you, until the next ...
(WHY ODOO, then I explain in more detail)
Note: Original text from my head, Reuse image according to GOOGLE

your code seems to return this year
request_url += urllib.urlencode(options)
AttributeError: module 'urllib' has no attribute 'urlencode'