Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # author: Bartlomiej "furas" Burek (https://blog.furas.pl)
- # 2018.05.28
- # 2020: currenlty to access GMail programs need special login/password generated on GMail,
- # it will not works with login/password used normally in web browser
- import imapclient
- import pyzmail
- imap = imapclient.IMAPClient('imap.gmail.com', use_uid=True)
- imap.login('your-login', 'your-password')
- #imap.select_folder('CRYPTO/trade', readonly=True)
- imap.select_folder('Inbox', readonly=True) # default folder with new messages
- unseen = imap.search(b'UNSEEN')
- for uid in unseen:
- print('uid:', uid)
- msg = imap.fetch([uid], [b'BODY[]', b'FLAGS'])
- trade = None
- message = pyzmail.PyzMessage.factory(msg[uid][b'BODY[]'])
- subject = message.get_subject()
- if 'strategy says sell now' in subject:
- print('sell signal found')
- print(subject)
- trade = 'sell'
- elif 'strategy says buy now' in subject:
- print('buy signal found')
- print(subject)
- trade = 'buy'
- else:
- print('failed')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement