Automating Buy and Sell Alert for Shares On Your Android Phone.
In my last post, I talked about a simple automation using a python API that constantly monitors price of shares I am interested in and tell me when I should buy and sell them. The API, when called returns a simple JSON which tells me which shares or scripts I should buy and which ones I should sell based:
Now that I have the API up and running, I need to call that using my mobile phone every hour during business hours and get notified if the price of a share changes and falls in the threshold where I need to act.
That way I can stop staring at my phone all the time and only look at share prices when something I want happens in the stock market.
Automation is all about deliberate and mindful attention and mindlessly staring at stock prices every couple of hours is no way to live specially when trading isn't your full time gig.
I've already talked about how I automate stuff on my android phone using Automagic. So let's use automagic to call this API every hour, parse the results and show alerts and notifications.
Automagic allows me to call an API and parse the JSON responses that I get back from the API using custom code. My overall workflow looks like this:
I use a periodic timer to fire every 25 minutes (you can make this as low or high as you want, even run it every minute if you like) during working hours (1o AM to 6 PM). In these runs, I fire an HTTP-Get (or post, depending on the API you are writing; mine uses a Get) and pass appropriate parameters. Here I'm just passing the username since it's a quick API I wrote using python just for myself.
Once I get the response back from the python script on server I can use the script action in automagic to write custom script to parse the response. My script looks like:
Now all my buy and sell are contained in a single variable call buysellscript which happens to be a list of strings and I can access that variable from anywhere in the workflow.
If you go back to the entire workflow diagram in the beginning of this post, the first thing I do after this script parsing the results, is check if the buysellscript variable has a list count of more than zero. This variable will have value (or a count / length of the list will be larger than 0) only if I need to buy or sell shares based on my high price, low price and the live market price of the shares I want to monitor.
If the variable has a value, I need to pay attention to my phone and act. So I use a speech output action and make my phone say out loud using google text-to-speech that I need to buy or sell specific scripts. The phone speaking out loud and telling me that I need to buy or sell specific shares not just grabs my attention but is also often a great conversation starter in parties and in office meetings. :)
Then I show the same message using a dialog box. I can even vibrate my phone in a certain way if I want. All of this grabs my attention when a share becomes worth buying or selling. For the rest of the time I can be completely free and blissfully unware of what the stock market is doing.
And just like that my stock trading pretty much runs on auto-pilot. Earlier I would monitor only a couple of stocks at a time, now I can literally set watches on dozens in my very own private database, set-and-forget, trust the workflow to inform me if something important happens to stocks I am monitoring and move on with my life.
I set fair buy and sell values of stocks every couple of days or weekends and update the database. Once I've done that, I stop looking at the stock prices. No Fear Of Missing Out, No constant distractions.
If you invest in stocks, what are you doing to automate or make your investing experience better? What other things grab your attention and make you stare at your mobile every few hours? Have you thought about automating those things?
A lot of people talk about automating a lot of things and some even take automation to extreme but for me the best automations are not just automations that save time, but automations that give you a peace of mind. Automations that assure you that if something you want to know about happens, you'll be informed. You don't need to be glued to your screen or on a app all the time! Automation isn't about becoming obsessed about saving a few minutes but about getting your life back and this by far is one of the really good examples of automation in my life that does exactly that.
Comments are closed.