mirror of
https://github.com/Death916/emailtrade.git
synced 2026-04-10 03:04:40 -07:00
small changes
This commit is contained in:
parent
136e0178da
commit
36ff320689
3 changed files with 10 additions and 15 deletions
|
|
@ -1,4 +1,3 @@
|
|||
import pyzmail
|
||||
import glogin
|
||||
import trade
|
||||
import history as hist
|
||||
|
|
@ -17,7 +16,7 @@ last_alert = 0
|
|||
|
||||
def start_buy():
|
||||
print('trade is a buy')
|
||||
trade.open_trade(1)
|
||||
trade.open_trade(0)
|
||||
global last_alert
|
||||
last_alert = "buy"
|
||||
hist.tradehist('buy test')
|
||||
|
|
@ -26,7 +25,7 @@ def start_buy():
|
|||
def start_sell():
|
||||
|
||||
print('trade is a sell')
|
||||
trade.close_trade(1)
|
||||
trade.close_trade(0)
|
||||
global last_alert
|
||||
last_alert = "sell"
|
||||
hist.tradehist('sell test')
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import logging
|
||||
|
||||
import time
|
||||
|
||||
|
||||
|
|
|
|||
18
trade.py
18
trade.py
|
|
@ -1,8 +1,5 @@
|
|||
#! python3
|
||||
|
||||
import json
|
||||
from bittrex import Bittrex
|
||||
|
||||
import history as hist
|
||||
|
||||
|
||||
|
|
@ -20,31 +17,30 @@ trex = Bittrex(api_key, priv_key)
|
|||
def marketcheck(ticker):
|
||||
markets = trex.get_ticker(ticker)
|
||||
price = markets['result']['Ask']
|
||||
print(ticker, 'price is ', markets)
|
||||
print(ticker, 'price is ', price)
|
||||
return price
|
||||
|
||||
|
||||
def open_trade(amount):
|
||||
global buyprice
|
||||
buyprice = marketcheck(ticker)
|
||||
amount = .0005 / buyprice
|
||||
#print(trex.buy_limit(ticker, amount, rate=buyprice))
|
||||
print('buying', amount, 'of', ticker)
|
||||
global buy_amount
|
||||
buy_amount = .0005 / buyprice
|
||||
# print(trex.buy_limit(ticker, amount, rate=buyprice))
|
||||
print('buying', buy_amount, 'of', ticker)
|
||||
hist.tradehist('bought ' + str(amount) + ' of ' + ticker + ' at ' + str(buyprice))
|
||||
print(buyprice)
|
||||
return
|
||||
|
||||
def close_trade(amount):
|
||||
global sellprice
|
||||
sellprice = marketcheck(ticker)
|
||||
amount = .0005 / sellprice
|
||||
#print(trex.sell_limit(ticker, amount, rate=sellprice))
|
||||
# print(trex.sell_limit(ticker, amount, rate=sellprice))
|
||||
print('selling', amount, 'of', ticker)
|
||||
hist.tradehist('sold ' + str(amount) + ' of ' + ticker + ' at ' + str(sellprice))
|
||||
hist.tradehist('profit = ' + '{:.20f}'.format((sellprice * amount) - (buyprice * amount)))
|
||||
hist.tradehist('profit = ' + '{:.20f}'.format((sellprice * amount) - (buyprice * buy_amount)))
|
||||
|
||||
def open_orders():
|
||||
trex.get_open_orders()
|
||||
return
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue