avatarSadi Saydam

Free AI web copilot to create summaries, insights and extended knowledge, download it at here

5582

Abstract

alcoholics, for reasons yet obscure, have lost the power of choice in drink. Our so-called will power becomes practically nonexistent. We are unable, at certain times, to bring into our consciousness with sufficient force the memory of the suffering and humiliation of even a week or a month ago. We are without defense against the first drink.</p></blockquote><blockquote id="b97c"><p>~ The Big Book, page 24.</p></blockquote><p id="2733">I mumbled something about doing more therapy sessions to stay in touch with my baseline feelings, but my new sponsor was having none of it.</p><p id="e1c9">‘This isn’t an emotional issue!’ he said, cutting in. ‘This is a memory issue that no amount of therapy you chose to throw money at will solve.’</p><p id="1800">He even suggested that the mental blank spot could be similar to a form of amnesia or dementia that science hasn’t picked up on yet.</p><p id="4ad6">‘But why hasn’t science picked up on it?’ I asked, holding the phone tightly.</p><p id="26fb">‘Probably because this blank spot only happens at certain times. Most of the time, it lays dormant.’ he replied before warning,</p><p id="337a">‘And unfortunately, this dormancy feature gives us an illusion of power. We think we’ve got sobriety now because our memory and willpower function normally again. Until, the condition randomly comes back online, and we relapse, leaving us totally baffled as to why it happened.’</p><p id="a3e9">My new sponsor sighed deeply.</p><p id="f455">‘It’s heartbreaking,’ he said softly. ‘Especially if you’ve relapsed after being multiple years clean. But it is sadly needed to show you that you are genuinely powerless, regardless of how much you desire and want to be sober.’</p><p id="969d">My head was spinning. Every sentence felt like the jolt of an electric cattle prod.</p><p id="8e0a">Later that day, I looked back at my recent relapses. I found no real conscious memory of consequences before any of them.</p><p id="352f">It appeared relapse was happening to me, not by me.</p><blockquote id="8aba"><p>As soon as I regained my ability to think, I went carefully over that evening in Washington. Not only had I been off guard, I had made no fight whatever against the first drink. This time I had not thought of the consequences at all. I had commenced to drink as carelessly as though the cocktails were ginger ale. I now remembered what my alcoholic friends had told me, how they prophesied that if I had an alcoholic mind, the time and place would come — I would drink again. They had said that though I did raise a defense, it would one day give way before some trivial reason for having a drink. Well, just that did happen and more, for what I had learned of alcoholism did not occur to me at all. I knew from that moment that I had an alcoholic mind. I saw that will power and self-knowledge would not help in those strange mental blank spots. I had never been able to understand people who said that a problem had them hopelessly defeated. I knew then. It was a crushing blow.</p></blockquote><blockquote id="93f7"><p>~ The Big Book, page 41.</p></blockquote><figure id="7922"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/0*n4r4HuNFWSnCD_WU"><figcaption>Photo by <a href="https://unsplash.com/@alicealinari?utm_source=medium&amp;utm_medium=referral">Alice Alinari</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h2 id="287c">A Belief That It Will All Be Alright.</h2><p id="baea">Sadly, the ‘blank spot’ wasn’t all that was happening.</p><p id="7c3e">My new sponsor later explained that something else was happening in my mind, a kind of twisting of my thinking that I couldn’t see either.</p><p id="02a0">This is the other main feature of the relapse condition.</p><p id="da70">The Big Book explains it as follows:</p><blockquote id="f067"><p>But there was always the curious mental phenomenon that parallel with our sound reasoning, there inevitably ran some insanely trivial excuse for taking the first drink. Our sound reasoning failed to hold us in check. The insane idea won out.</p></blockquote><blockquote id="4ad8"><p>~ The Big Book, page 37.</p></blockquote><p id="da58">Anytime the ‘good idea’ of relapsing suddenly popped into my head, part of me would start to minimise the lunacy of this thought.</p><p id="e2c7">I would begin to rationalise this catastrophic idea with excuses and reasons why it would be, in fact, okay to relapse despite being in recovery.</p><p id="432a">No matter how insignificant and non-sensical those reasons were, they quickly became plausible and seemingly rational.</p><p id="6997">At the same time, the urge to want to relapse would start to surge.</p><p id="cdc4">A fear of missing out would relentlessly come crashing in like waves rolling in and out of my consciousness.</p><p id="b225">Thoughts and narratives of why it would be okay this time would dominate my thinking.</p><p id="fe2d">Finally, a tidal wave of justification would smother me into deep unconsciousness.</p><p id="c65b">Convinced of my rationale, I would carry out my plan, only to revert back to type and do everything I said I wouldn’t do, and again, find myself powerless to stop once I started.</p><p id="34a2">This twisted thinking was nothing more than a lie, but I believed the lie and didn’t see the flaw in the logic in light of my track record with partying.</p><p id="888a">To any average person, this kind of thinking and decision-making would be termed irrational, unsound, or even insa

Options

ne.</p><p id="d880">The Big Book calls this thinking an <i>‘obsession to beat the game’</i>.</p><p id="9087">Whether it’s a vague idea that this time it would be different, that I would do it differently and party like a gentleman.</p><p id="b075">Or the well-loved excuse that this will be my last relapse. After this final time, I’ll be done for good. I’ll get on with my life.</p><p id="be67">But, it never was different and that last time never did happen.</p><p id="149d">My new sponsor would remind me often,</p><p id="a62b" type="7">‘You aren’t changing your mind when you’ve decided to give in and party; your mind has been changed for you.’</p><h2 id="4c19">It Centers In Our Minds</h2><p id="f0e7">Of course, there is a body element for the addict.</p><p id="86b6">Naturally, as a consequence of the constant extreme usage of powerfully addictive substances and processes that are designed by their very nature to make you want more and more, addicts have developed a sky-high tolerance.</p><p id="2d70">But there’s this annihilation approach to our acting out and using once we start, which the Big Book describes as the <i>‘phenomenon of craving’</i>.</p><p id="01c2">In the Doctor’s opinion in the Big Book, Dr. Silkworth calls the phenomenon of craving an ‘allergy’, but my new sponsor wasn’t too keen on that idea.</p><p id="10af" type="7">‘If it’s an allergy, then why doesn’t the phenomenon of craving happen every time?’</p><p id="ae75">Regardless of whether it is an allergy, the body part becomes irrelevant, as most people with a severe peanut allergy don’t tend to keep repeating the total lost cause of trying to have another peanut to see if they will react differently.</p><p id="2e48">They don’t touch or go anywhere near peanuts because they remember how terrible it was last time.</p><p id="436a">Once or twice is enough.</p><p id="3796">Not so with the real addict because of the first two features of the disease; they will not only be back gorging on peanuts, but they will eventually take up residence in a peanut factory.</p><blockquote id="e3f6"><p>There is a complete failure of the kind of defence that keeps one from putting his hand on a hot stove. The alcoholic may say to himself in the most casual way, “It won’t burn me this time, so here’s how!” Or perhaps he doesn’t think at all.</p></blockquote><blockquote id="d5e6"><p>~ The Big Book, page 24.</p></blockquote><p id="5cb9">That’s why the Big Book says the real problem ‘centers in our mind’, not our bodies.</p><p id="22d4">‘What will happen now,’ my new sponsor forewarned, ‘as the relapses get worse, the time between them will get shorter and shorter.’</p><p id="6f0b">This condition is progressive.</p><p id="e8f1">Therefore, the blanking and twisting will naturally grow in scope and reach until you can no longer differentiate the true from the false.</p><h2 id="869b">Turning To Something Else</h2><p id="922a">If you believe in the disease concept of addiction, that this is a disease, a fatal illness precisely like any other life-threatening condition, then you have it for life.</p><p id="a2d8">There is <b>nothing </b>you can do to change that.</p><p id="d5f6">If you constantly can’t remember why or how you relapsed despite your honest desire not to.</p><p id="9aaf">Or if you continually relapse, believing some trivial reason or silly excuse to relapse while dismissing the genuine consequences, then you are a real addict.</p><p id="a47a">You have this relapse condition.</p><p id="840d">You <b>crossed a threshold </b>where, at certain times, your inability to use reasoning and rational thinking won’t even register for you.</p><p id="d8c6">The tragic truth is that once that threshold has been crossed, you have <b>no choice</b> but to relapse.</p><p id="0564">A compromised part of your brain will always fire the thought of using or acting out. That will never change. It’s wired like that for life.</p><p id="5fb0">There is no cure.</p><p id="fcca">Even this information won’t save you, as at certain times, you won’t be able to recall any of it when it matters.</p><p id="7fc5">So, let go of trying to change that.</p><p id="59f9">Let go of any old ideas around fighting it and instead get out of the way and <b>trust in something else</b>.</p><p id="b722">After all, that’s all you’ve got.</p><p id="5065">There’s nothing you or anyone else can do to stop this relapse condition.</p><p id="d1dd">But there’s everything you can do about everything else.</p><p id="5e51">There’s everything you can do about building a <b>spiritual dimension</b> to your life, by giving back, helping others, living in genuine faith and trusting in something greater than you.</p><p id="3096">There’s everything you can do to improve your awareness and intuition, raise your consciousness and develop another part of your brain.</p><p id="7598">And let this part of your brain grow bigger and stronger than that addictive part so that it can embrace and look after that compromised part.</p><p id="d2e3">Just like a bigger and wiser older sibling can care for and comfort a much younger upset sibling by giving that stressed child a big hug.</p><p id="da93">There’s everything you can do about deciding to take on a new attitude, direction, and way of life that will keep this condition dormant one day at a time.</p><p id="e415">If this article speaks to you, please follow, share and subscribe to me for more.</p><p id="fc50">Click <a href="https://twitter.com/TheDarrenJames">here</a> to follow me on <a href="https://twitter.com/TheDarrenJames">X</a>.</p></article></body>

How to Build a Stock Price Alert Using Python

A simple step by step guide to building a Python stock alert. You will never miss the price you want.

Image credit Pixabay

There can be a million reasons why you would invest in stocks. You want to be rich like Warren Buffet, you want to save up for retirement, or you just don’t want to miss out on the rising stock market ride.

Whatever your reason might be, you need to be aware of the price of the stock you’re interested in. Here is a simple guide to set up an email alert to notify when a stock reaches the price you desire.

Setting up Python on your device (skip if you have it set up already)

If you’re reading this article I will assume that you have Python installed and have your favorite code editor set up.

If not, here is a great guide to get you started, come back after you review it to follow along.

Steps to take:

  • Get API key from Alpha Vantage
  • Import relevant packages
  • Pull the data from Alpha Vantage
  • Picking the relevant data
  • Setting up an email notification
  • Notes

Get API key from Alpha Vantage

Alpha Vantage provides free stock data. They were build to democratize the access to data for the purpose of using in projects such as this.

Normally you would have to go through a paid service or scrape the data off of Yahoo Finance or another service.

To pull your data from Alpha Vantage, you will need to receive an API key. Follow this link to their website which looks like this:

Screenshot of https://www.alphavantage.co by the Author

Click on the “Get your free API key today”

Image credit by Author

Once you fill the little form above, you will be given an API key which will enable you to pull data from Alpha Vantage. Take a note of the API key and let’s jump into our Code editor.

Import relevant packages

To get started with our project we need to make sure that we have all the relevant packages installed and imported. If you don’t know how to install packages you can learn it from here:

import pandas as pd #data manipulation and analysis package
from alpha_vantage.timeseries import TimeSeries #enables data pull from Alpha Vantage
import matplotlib.pyplot as plt #if you want to plot your findings
import time
import smtplib #enables you to send emails

Pulling the data from Alpha Vantage

Here we will use the API key we just obtained from above, on the example below you will find the one I used while building the project initially:

#Getting the data from alpha_vantage
ts = TimeSeries(key='CZK4PSW4EWOIOSUG', output_format='pandas')
data, meta_data = ts.get_intraday(symbol='MSFT',interval='1min', outputsize='full')

On the first line, you are creating a time-series data frame and telling python to have the format as a pandas data frame.

In this case, I have used Microsoft or MSFT but you can use your own stocks. A couple of examples would be:

  • AAPL — Apple
  • AMZN — Amazon
  • FB — Facebook

If you’re unsure about the ticker of your stock, you can go to Yahoo Finance and type in the company you’re interested in. It will display the stock ticker for you.

Another input that you can specify is the interval in which you want the program to pull data. I have specified 1min for the interval. A couple of other options include:

  • 1min, 5min, 15min, 30min, 60min

To try and explore more options I recommend you read the Alpha Vantage documentation here.

Picking the right data

Alpha Vantage will by default output the following information for a stock.

For the purposes of this project, we will only use the close column which indicates the closing price of the stock.

Other columns if you’re interested: open, high, low, close, volume

#We are currently interested in the latest price
close_data = data['4. close'] #The close data column
last_price = close_data[0] #Selecting the last price from the close_data column
#Check if you're getting a correct value
print(last_price) 

*usually [0] would get you the first element however, on this instance, the prices are listed in reverse order.

The output was:$ 220.9 as of Aug 26, 20:00

Setting up the email notification

Now that we are able to pull the latest prices of the stock we desire. We can set up an email alert to notify us when the time is right.

#Set the desired message you want to see once the stock price is at a certain level
sender_email = "[email protected]" #The sender email
rec_email = "[email protected]" #The receiver email
password = ("password") #The password to the sender email
message = "MSFT STOCK ALERT!!! The stock is at above price you set " + "%.6f" % last_price  #The message you want to send

Below we will set up the condition and the trigger that will cause the email to be sent to us when the time is right.

Let’s assume that you own a bunch of MSFT stock that you bought for $150 a share, and you want to sell them at a profit.

Thetarget_sell_price variable enables you to set the limit you want.

For example, you might believe that the stock price is too high right now and want to get out.

Or you think that you will have sufficient profits at the $220.00 price level. Thus, you can use that limit as your alert price.

It is totally up to you to enter your desired number.

target_sell_price = 220 #enter the price you want to sell at
if last_price > target_sell_price:
    server = smtplib.SMTP('smtp.gmail.com', 587)
    server.starttls()
    server.login(sender_email, password) #logs into your email account
    print("Login Success") #confirms that you have logged in succesfully
    server.sendmail(sender_email, rec_email, message) #send the email with your custom mesage
    print("Email was sent") #confirms that the email was sent 

You’re DONE!

If everything went as planned you should expect to find an email like this:

Image credit Author

Here is the full code for your reference:

import pandas as pd #data manipulation and analysis package
from alpha_vantage.timeseries import TimeSeries #enables data pull from Alpha Vantage
import matplotlib.pyplot as plt #if you want to plot your findings
import time
import smtplib #enables you to send emails
#Getting the data from alpha_vantage
ts = TimeSeries(key='CZK4PSW4EWOIOSUG', output_format='pandas')
data, meta_data = ts.get_intraday(symbol='MSFT',interval='1min', outputsize='full')
#We are currently interested in the latest price
close_data = data['4. close'] #The close data column
last_price = close_data[0] #Selecting the last price from the close_data column
#Check if you're getting a correct value
print(last_price)
#Set the desired message you want to see once the stock price is at a certain level
sender_email = "[email protected]" #The sender email
rec_email = "[email protected]" #The receiver email
password = ("password")#The password to the sender email
message = "MSFT STOCK ALERT!!! The stock is at above price you set " + "%.6f" % last_price #The message you want to send
target_sell_price = 220 #enter the price you want to sell at
if last_price > target_sell_price:
    server = smtplib.SMTP('smtp.gmail.com', 587)
    server.starttls()
    server.login(sender_email, password) #logs into your email account
    print("Login Success")#confirms that you have logged in succesfully
    server.sendmail(sender_email, rec_email, message)#send the email with your custom mesage
    print("Email was sent") #confirms that the email was sent

Notes

  • If you copy and paste the full code above DO NOT forget to enter your own email and password information.
  • Make sure to use your own API key obtained by Alpha Vantage
  • By no means is this a trading or stock investment advice
  • If you get an error saying your password is rejected, you might want to configure the “Less secure apps” settings on your (assuming you use a Gmail account) Gmail account here. This will enable your program to access your Google account and send an email on your behalf, otherwise, Google will reject the request from your program.

A couple of improvement ideas

  • You can add more stocks to your tracker and set buy/sell targets
  • You can make the email look better and create an email service (or have fun with your friends. To format your Python emails check this out.
  • You can create more sophisticated indicators such as: change_in_price to seek volatility.

I hope that this simple walkthrough helps you dip your toes in the water. Even if you’re not a coder I hope you were able to follow through. Happy coding!!

You might also find this interesting:

Programming
Python
Stock Analysis
Coding
Technology
Recommended from ReadMedium