Skip to content

Instantly share code, notes, and snippets.

View McKlayne's full-sized avatar
🎯
Focusing

McKlayne Marshall McKlayne

🎯
Focusing
View GitHub Profile
def define_edges(crypto_ids, crypto_abbreviations, crypto_data):
# initialize the graph and an empty list for edges
graph = nx.DiGraph()
edges = []
# define all edges and add to graph
for coin1 in crypto_ids:
for coin2 in crypto_ids:
if coin1 != coin2:
# find the index of coin1 and coin2 in the ids list. Use those values to get the abbreviations
def get_coingecko_data(crypto_ids, crypto_abbreviations):
# define the base url and another piece that will be added later
base = 'https://api.coingecko.com/api/v3/simple/price?ids='
vs_currencies_string= '&vs_currencies='
# determine the number of ids in the list. This will help us know how many commas to add to the url
id_remaining = len(crypto_ids)
# loop through each coin and append its id to the url. Decrease id_remaining each iteration, add a comma to the url if it is needed
for coin in crypto_ids:
# load required packages (must be previously installed)
import json
import requests
import networkx as nx
from itertools import combinations
import pandas as pd
pd.options.display.max_rows = 1000
# define the lists of ids and abbreviations
# make sure the abbreviations are in the same order as the corresponding cryptos in the id_list
import cbpro
import os
import websocket
import pprint
import ta
import numpy as np
import pandas as pd
import cbpro, time
public_client = cbpro.PublicClient()
@McKlayne
McKlayne / trade.py
Last active January 30, 2021 23:34
import os
import alpaca_trade_api as tradeapi
import pandas as pd
import numpy as np
import boto3
import ta
s3 = boto3.client('s3')
sns = boto3.client('sns')
# Define function directory
ARG FUNCTION_DIR="/function"
FROM python:buster as build-image
# Install aws-lambda-cpp build dependencies
RUN apt-get update && \
apt-get install -y \
g++ \
make \
import sys
def handler(event, context):
return 'Hello from AWS Lambda using Python' + sys.version + '!'
import pandas as pd
import sklearn
import xgboost as xgb
def handler(event, context):
message = []
message.append('The xgboost version is {}.'.format(xgb.__version__))
message.append('The scikit-learn version is {}.'.format(sklearn.__version__))
message.append('The pandas version is {}.'.format(pd.__version__))
import pandas as pd
import sklearn
import xgboost as xgb
def handler(event, context):
message = []
message.append('The xgboost version is {}.'.format(xgb.__version__))
message.append('The scikit-learn version is {}.'.format(sklearn.__version__))
message.append('The pandas version is {}.'.format(pd.__version__))
# Define function directory
ARG FUNCTION_DIR="/function"
FROM python:buster as build-image
# Install aws-lambda-cpp build dependencies
RUN apt-get update && \
apt-get install -y \
g++ \
make \