mirror of
https://github.com/Death916/emailtrade.git
synced 2026-04-10 03:04:40 -07:00
tests
This commit is contained in:
parent
78a2842d6f
commit
efb0b43edf
1 changed files with 11 additions and 9 deletions
20
trade.py
20
trade.py
|
|
@ -1,7 +1,8 @@
|
|||
#! python3
|
||||
|
||||
import json
|
||||
from bittrex.bittrex import Bittrex
|
||||
from bittrex.bittrex import Bittrex, API_V2_0
|
||||
from bittrex import Bittrex as trex1
|
||||
import history as hist
|
||||
|
||||
amount = 0
|
||||
|
|
@ -13,22 +14,23 @@ 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)
|
||||
trex = Bittrex(api_key, priv_key, api_version=API_V2_0)
|
||||
|
||||
|
||||
def marketcheck(ticker):
|
||||
markets = trex.get_ticker(ticker)
|
||||
price = markets['result']['Ask']
|
||||
#print(markets['result'])
|
||||
markets = trex.get_latest_candle(ticker, 'fiveMin')
|
||||
#price = markets['result']['Ask']
|
||||
print(markets)
|
||||
return price
|
||||
|
||||
|
||||
def open_trade(amount):
|
||||
global buyprice
|
||||
buyprice = marketcheck(ticker)
|
||||
trex.buy_limit(ticker, amount, rate = None)
|
||||
trex.buy_limit(ticker, amount, rate = buyprice)
|
||||
print('buying', amount, 'of', ticker)
|
||||
hist.tradehist('bought ' + amount + ' of ' + ticker + ' at ' + str(buyprice))
|
||||
print(buyprice)
|
||||
|
||||
def close_trade(amount):
|
||||
global sellprice
|
||||
|
|
@ -43,6 +45,6 @@ def open_orders():
|
|||
|
||||
|
||||
|
||||
open_trade('1')
|
||||
close_trade('1')
|
||||
|
||||
#open_trade('.00051')
|
||||
#close_trade('1')
|
||||
marketcheck(ticker)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue