Skip to content

Instantly share code, notes, and snippets.

View clintmjohnson's full-sized avatar

Clint Johnson clintmjohnson

View GitHub Profile
@clintmjohnson
clintmjohnson / binancealerts.py
Created January 10, 2018 02:34
Send Crypto Currency price Alerts via Text, using Binance API
def alertonlow():
""" This Program uses the Binance API to Send Text Alerts for Price Action. Right now it's set up to
send a Text Alert, when any Crypto Coin is Less than or Equal to 2% of the 24HR Low """
from binance.client import Client
from twilio.rest import Client as twilioclient
twilioclientsid = '' # Twilio User ID
twilioclienttok = '' # Twilio User Token
@clintmjohnson
clintmjohnson / wordtonumber.py
Created October 19, 2017 20:20
Convert Word numbers to Integer numbers
import re
from nltk.corpus import stopwords
Small = {
'zero': 0,
'one': 1,
'two': 2,
'three': 3,
'four': 4,
@clintmjohnson
clintmjohnson / textblob.py
Created October 18, 2017 19:46
TextBlob Sample Usage
from textblob import TextBlob
text = """TextBlob aims to provide access to common text-processing operations through a familiar interface. /
You can treat TextBlob objects as if they were Python strengs that learned how to do Natural Language Processing."""
#"This is bad " = Sentiment Sentiment(polarity=-0.6999999999999998, subjectivity=0.6666666666666666)
#"This is Good" = Sentiment Sentiment(polarity=0.7, subjectivity=0.6000000000000001)
blob = TextBlob(text)
@clintmjohnson
clintmjohnson / google_vision.py
Created October 17, 2017 21:17
This Python program connects to Google Vision API, to identify Images
def google_vision():
import io
import os
from google.cloud import vision
from google.cloud.vision import types
#https://cloud.google.com/vision/docs/auth
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = "Path to Application default credentials JSON ADC"
@clintmjohnson
clintmjohnson / poloniex_crypto_watch.py
Last active October 11, 2017 18:52
Crypto Currency watch with Poloniex
def cryptoprices(pair):
from poloniex import Poloniex
apiKey = ""
secret = ""
polo = Poloniex(apiKey, secret)
market_data = polo.returnTicker()[pair]
bid = market_data["highestBid"]
@clintmjohnson
clintmjohnson / Historic_Stock_Download
Created October 10, 2017 22:33
This Function downloads Historic stock prices for a Symbol, and Saves them to CSV file, using Pandas and Yahoo finance API
"""
This function combines data from Pandas data on stocks, and the Yahoo Finance API
"""
def stockhistory(stock2check):
import pandas_datareader.data as web
import datetime
from yahoo_finance import Share
stock = Share(stock2check)
ylp = stock.get_year_low() # Returns the Year Low price for the stock
@clintmjohnson
clintmjohnson / gist:2ab673ba31489e6aa0ef694b9d9f892e
Created October 4, 2017 21:07
Historic Stock Price Data Download to CSV
import pandas as pd
import io
import requests
import time
def google_stocks(symbol, startdate=(1, 1, 2005), enddate=None):
startdate = str(startdate[0]) + '+' + str(startdate[1]) + '+' + str(startdate[2])
if not enddate:
@clintmjohnson
clintmjohnson / Stock Tracker
Last active October 2, 2017 19:52
This Python program Tracks Sample Stock buying and selling, using Yahoo Finance live Data
def stocktrack(stock,buysell,qty):
import sqlite3
from yahoo_finance import Share
conn = sqlite3.connect('Stocks.db')
c = conn.cursor()
c.execute('''CREATE TABLE IF NOT EXISTS stocks
(date text, trans text, symbol text, qty real, price real, total real)''')
@clintmjohnson
clintmjohnson / scrapeamazonproducts.py
Last active October 18, 2017 20:08
This program scrapes Product Details from ASIN from Amazon.
from lxml import html
import csv, os, json
import requests
#from exceptions import ValueError
from time import sleep
def AmzonParser(url):
headers = {
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/537.36'}
@clintmjohnson
clintmjohnson / MSSQL_Python.py
Last active November 26, 2015 16:37
This Gist Uses Python and SQL Server - It queries results from a MSSQL table and appends the results to a python list
import _mssql
# Connect to the SQL Server Database
conn = _mssql.connect(server='Servernamehere', user='serverusername', password='serverpassword', \
database='databasename')
# Run The Select Query against the Database
conn.execute_query('SELECT TOP 10 [Item ID],[Custom Label],[Quantity Available] FROM [bsusa_active_staging]')
# Create the Lists