A 90’s pearler.
A 90’s pearler.
Never gets old.
I receive daily activity statements from my broker and I wanted to download them, extract the data into a MySQL database and then archive the statement on the hard drive. The first part is downloading the attachment, and then moving the email to another imap folder, which is something I had trouble with in Gmail. I use Python to do it, and the email and imaplib packages. Here’s a look at the code that moves all the messages in the inbox from a single recipient to another imap folder.
import Messaging, Util, Const import email, imaplib, os m = imaplib.IMAP4_SSL(Const.IMAP_SERVER) m.login(Const.IMAP_USER, Const.IMAP_PWD) m.select() resp, items = m.search(None, 'FROM', '"email@example.com"') items = items.split() for emailid in items: resp, data = m.fetch(emailid, "(RFC822)") if resp == 'OK': email_body = data.decode('utf-8') mail = email.message_from_string(email_body) if mail.get_content_maintype() != 'multipart': continue if mail["Subject"].find("Activity Statement") > 0: print("Moving message " + mail["Subject"] + " to " + Const.IMAP_DEST_FOLDER) result = m.store(emailid, '+X-GM-LABELS', Const.IMAP_DEST_FOLDER) #result = m.store(emailid, '+FLAGS', '\\Deleted') mov, data = m.uid('STORE', emailid , '+FLAGS', '(\Deleted)') m.expunge() m.close()
I use another file called Const.Py to store all my configurations, so change those to whatever you need. The key here is to change the label with the line “result = m.store(emailid, ‘+X-GM-LABELS’, Const.IMAP_DEST_FOLDER)”, and then add the “Deleted” flag, before expunging the inbox.
The Nasdaq futures (NQ) broke out of resistance at 4,441.50 but got promptly rejected at 4,450. That failed breakout look very bearish to me, and I think we could find ourselves going lower in the next few days.
Below us there is good looking demand at 4,205.75, which is where I’ll be starting to look for a long.
Looking at the weekly chart, with indicators courtesy of Emini-watch, you can see that we put in a pullback to end of trend, with a yellow amateur bar trying to get long at the top. The picture is quite bearish.
I currently have a short order placed at 4,401.75, from a small 2 minute zone.
Most of my trading has been done on Tradestation, which still in my opinion has one of the best platforms out there as far as ease of use goes. When I switched to Interactive Brokers I found it quite an adjustment getting used to Trader Workstation – the IB platform. You can do most everything TS does in this platform, but it is all done a little differently so it takes some time to adjust.
One of the things I battled with was adding an OCO for a target and a stop for an existing position. What I usually do is get into a position with a limit order and a stop, and then add the target at a later stage. It’s not a good habit, and something I am changing. Having said that, if you find yourself in a position, wanting to add an OCO (order-cancels-order) for a profit target and a stop, here is how you do it.
It’s a lot more work than doing it in TS, but the result is the same and once you get used to it, it really isn’t all that bad. The only thing I wish you could do was place multiple target orders at the same time.