From be318e7e1b303fc7a3ad03716f1bfae0e7dd512a Mon Sep 17 00:00:00 2001 From: Death916 Date: Thu, 24 May 2018 01:01:49 -0700 Subject: [PATCH] start buy and sell functions --- getsignal.py | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/getsignal.py b/getsignal.py index bd7ba9e..3cef4a7 100644 --- a/getsignal.py +++ b/getsignal.py @@ -7,7 +7,6 @@ import glogin #login to server imap = glogin.connect() imap.select_folder('CRYPTO/trade', readonly=True) - alert = imap.search(b'UNSEEN') #get all unseen uids @@ -15,28 +14,36 @@ for num in range(0, 100000): if num in alert: uid = num - msg = imap.fetch([uid], [b'BODY[]', b'FLAGS']) - - message = pyzmail.PyzMessage.factory(msg[uid][b'BODY[]']) + trade = None + +def start_buy(): + if trade == "buy": + print('trade is a buy') + +def start_sell(): + if trade == "sell": + print('trade is a sell') + + + if 'strategy says sell now' in message.get_subject(): - print('sell signal found') - print(message.get_subject()) - trade = sell + print('sell signal found') + print(message.get_subject()) + trade = "sell" + elif 'strategy says buy now' in message.get_subject(): print('buy signal found') print(message.get_subject()) - trade = buy - + trade = "buy" else: print('failed') -#class start_trade(): - -# \ No newline at end of file +#start_buy() +#start_sell() \ No newline at end of file