forked from ndri/python-bittrex
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.py
More file actions
69 lines (53 loc) · 1.74 KB
/
example.py
File metadata and controls
69 lines (53 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env python
"""Example program.
This program buys some Dogecoins and sells them for a bigger price.
"""
from bittrex import Bittrex
import os
import sys
module_path = os.path.abspath(os.path.join('..'))
if module_path not in sys.path:
sys.path.append(module_path)
from helpers.exchange_helpers import BittrexHelpers
exchange = None # 'Bittrex'
# Get these from https://bittrex.com/Account/ManageApiKey
if(exchange == 'Bittrex'):
bh = BittrexHelpers()
bh.get_account_data()
key = bh.get_key()
secret = bh.get_secret()
else:
key = 'key'
secret = 'secret'
api = Bittrex(key, secret)
# Market to trade at
trade = 'BTC'
currency = 'DOGE'
market = '{0}-{1}'.format(trade, currency)
# Amount of coins to buy
amount = 100
# How big of a profit you want to make
multiplier = 1.1
# Getting the BTC price for DOGE
dogesummary = api.getmarketsummary(market)
dogeprice = dogesummary[0]['Last']
print('The price for {0} is {1:.8f} {2}.'.format(currency, dogeprice, trade))
# Buying 100 DOGE for BTC
# print('Buying {0} {1} for {2:.8f} {3}.'.format(amount, currency, dogeprice,
# trade))
# api.buylimit(market, amount, dogeprice)
# # Multiplying the price by the multiplier
# dogeprice = round(dogeprice * multiplier, 8)
# # Selling 100 DOGE for the new price
# print('Selling {0} {1} for {2:.8f} {3}.'.format(amount, currency, dogeprice,
# trade))
# api.selllimit(market, amount, dogeprice)
# Gets the DOGE balance
dogebalance = api.getbalance(currency)
try:
print("Your balance is {0} {1}.".format(dogebalance['Available'],
currency))
except TypeError:
print("Error in API call to getbalance: {}".format(dogebalance))
# For a full list of functions, check out:
# bittrex.py or https://bittrex.com/Home/Api