mirror of
https://github.com/Death916/emailtrade.git
synced 2026-04-10 03:04:40 -07:00
formatting
This commit is contained in:
parent
118ce341df
commit
214bcd1f48
1 changed files with 14 additions and 12 deletions
26
trade.py
26
trade.py
|
|
@ -1,8 +1,8 @@
|
|||
#! python3
|
||||
|
||||
import json
|
||||
from bittrex.bittrex import Bittrex, API_V2_0
|
||||
from bittrex import Bittrex as trex1
|
||||
from bittrex import Bittrex
|
||||
|
||||
import history as hist
|
||||
|
||||
amount = 0
|
||||
|
|
@ -14,37 +14,39 @@ with open('D:/code/emailtrade/keys.json') as k:
|
|||
api_key = keys['api_key']
|
||||
priv_key = keys['priv_key']
|
||||
ticker = 'BTC-ETH'
|
||||
trex = Bittrex(api_key, priv_key, api_version=API_V2_0)
|
||||
trex = Bittrex(api_key, priv_key)
|
||||
|
||||
|
||||
def marketcheck(ticker):
|
||||
markets = trex.get_latest_candle(ticker, 'fiveMin')
|
||||
#price = markets['result']['Ask']
|
||||
print(markets)
|
||||
markets = trex.get_ticker(ticker)
|
||||
price = markets['result']['Ask']
|
||||
#print(markets)
|
||||
return price
|
||||
|
||||
|
||||
def open_trade(amount):
|
||||
global buyprice
|
||||
buyprice = marketcheck(ticker)
|
||||
trex.buy_limit(ticker, amount, rate = buyprice)
|
||||
#print(trex.buy_limit(ticker, amount, rate=price))
|
||||
print('buying', amount, 'of', ticker)
|
||||
hist.tradehist('bought ' + amount + ' of ' + ticker + ' at ' + str(buyprice))
|
||||
hist.tradehist('bought ' + str(amount) + ' of ' + ticker + ' at ' + str(buyprice))
|
||||
print(buyprice)
|
||||
return
|
||||
|
||||
def close_trade(amount):
|
||||
global sellprice
|
||||
sellprice = marketcheck(ticker)
|
||||
trex.sell_limit(ticker, amount, rate = None)
|
||||
#print(trex.sell_limit(ticker, amount, rate = None))
|
||||
print('selling', amount, 'of', ticker)
|
||||
hist.tradehist('sold ' + amount + ' of ' + ticker + ' at ' + str(sellprice))
|
||||
hist.tradehist('profit = ' + str(sellprice - buyprice))
|
||||
hist.tradehist('sold ' + str(amount) + ' of ' + ticker + ' at ' + str(sellprice))
|
||||
hist.tradehist('profit = ' + '{:.20f}'.format((sellprice * amount) - (buyprice * amount)))
|
||||
|
||||
def open_orders():
|
||||
trex.get_open_orders()
|
||||
return
|
||||
|
||||
|
||||
|
||||
#open_trade('.00051')
|
||||
#close_trade('1')
|
||||
marketcheck(ticker)
|
||||
#marketcheck(ticker)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue