mirror of
https://github.com/Death916/emailtrade.git
synced 2026-04-10 03:04:40 -07:00
add logging
This commit is contained in:
parent
fb37e718b3
commit
154b1faf72
1 changed files with 13 additions and 7 deletions
20
trade.py
20
trade.py
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
import json
|
import json
|
||||||
from bittrex.bittrex import Bittrex
|
from bittrex.bittrex import Bittrex
|
||||||
|
import history as hist
|
||||||
|
|
||||||
amount = 0
|
amount = 0
|
||||||
price = 0
|
price = 0
|
||||||
|
|
@ -19,24 +19,30 @@ trex = Bittrex(api_key, priv_key)
|
||||||
def marketcheck(ticker):
|
def marketcheck(ticker):
|
||||||
markets = trex.get_ticker(ticker)
|
markets = trex.get_ticker(ticker)
|
||||||
price = markets['result']['Ask']
|
price = markets['result']['Ask']
|
||||||
print(markets['result'])
|
#print(markets['result'])
|
||||||
return price
|
return price
|
||||||
|
|
||||||
|
|
||||||
def open_trade(amount):
|
def open_trade(amount):
|
||||||
marketcheck(ticker)
|
global buyprice
|
||||||
trex.buy_limit(ticker, amount, rate=None)
|
buyprice = marketcheck(ticker)
|
||||||
|
trex.buy_limit(ticker, amount, rate = None)
|
||||||
print('buying', amount, 'of', ticker)
|
print('buying', amount, 'of', ticker)
|
||||||
|
hist.tradehist('bought ' + amount + ' of ' + ticker + ' at ' + str(buyprice))
|
||||||
|
|
||||||
def close_trade(amount):
|
def close_trade(amount):
|
||||||
marketcheck(ticker)
|
global sellprice
|
||||||
trex.sell_limit(ticker, amount, rate =None)
|
sellprice = marketcheck(ticker)
|
||||||
|
trex.sell_limit(ticker, amount, rate = None)
|
||||||
print('selling', amount, 'of', ticker)
|
print('selling', amount, 'of', ticker)
|
||||||
|
hist.tradehist('sold ' + amount + ' of ' + ticker + ' at ' + str(sellprice))
|
||||||
|
hist.tradehist('profit = ' + str(sellprice - buyprice))
|
||||||
|
|
||||||
def open_orders():
|
def open_orders():
|
||||||
trex.get_open_orders()
|
trex.get_open_orders()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#open_buy('1')
|
open_trade('1')
|
||||||
|
close_trade('1')
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue