This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask | |
app = Flask(__name__) | |
@app.route("/") | |
def hello(): | |
return "Hello world!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from models.PyCryptoBot import PyCryptoBot | |
from models.exchange.coinbase_pro import PublicAPI as CPublicAPI | |
from models.Trading import TechnicalAnalysis | |
app = PyCryptoBot(exchange='coinbasepro') | |
api = CPublicAPI() | |
df = app.getHistoricalDataChained('BTC-GBP', 3600, 5) | |
model = TechnicalAnalysis(df) | |
model.addAll() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import boto3 | |
import botocore.config | |
import pymysql | |
client = boto3.client('s3', 'eu-west-1', config=botocore.config.Config(s3={'addressing_style':'path'})) | |
def lambda_handler(event, context): | |
bucket_name = event["Records"][0]["s3"]["bucket"]["name"] | |
s3_file_name = event["Records"][0]["s3"]["object"]["key"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import boto3 | |
import email | |
import os | |
from datetime import datetime | |
import re | |
def get_timestamp(): | |
current = datetime.now() | |
return(str(current.year) + '-' + str(current.month) + '-' + str(current.day) + '-' + str(current.hour) + '-' + str(current.minute) + '-' + str(current.second)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def mount_gdrive(): | |
if not os.path.isdir('/content/gdrive'): | |
drive.mount('/content/gdrive') | |
def build(): | |
root_dir = os.environ['GDRIVE_ROOT'] | |
project_name = os.environ['PROJECT_NAME'] | |
tensorflow_model = os.environ['TENSORFLOW_MODEL'] | |
os.chdir(f'/content/gdrive/MyDrive/{root_dir}/models/research') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def mount_gdrive(): | |
if not os.path.isdir('/content/gdrive'): | |
drive.mount('/content/gdrive') | |
def create_gdrive_directory_structure(): | |
global labels | |
root_dir = os.environ['GDRIVE_ROOT'] | |
project_name = os.environ['PROJECT_NAME'] | |
tensorflow_model = os.environ['TENSORFLOW_MODEL'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" Sample TensorFlow XML-to-TFRecord converter | |
usage: generate_tfrecord.py [-h] [-x XML_DIR] [-l LABELS_PATH] [-o OUTPUT_PATH] [-i IMAGE_DIR] [-c CSV_PATH] | |
optional arguments: | |
-h, --help show this help message and exit | |
-x XML_DIR, --xml_dir XML_DIR | |
Path to the folder where the input .xml files are stored. | |
-l LABELS_PATH, --labels_path LABELS_PATH | |
Path to the labels (.pbtxt) file. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from datetime import datetime | |
import matplotlib.pyplot as plt | |
def cbpGetHistoricRates(market='BTC-GBP', granularity=86400, iso8601start='', iso8601end=''): | |
api = 'https://api.pro.coinbase.com/products/' + market + '/candles?granularity=' + \ | |
str(granularity) + '&start=' + iso8601start + '&end=' + iso8601end | |
resp = requests.get(api) | |
if resp.status_code != 200: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://levelup.gitconnected.com/trading-using-python-simple-moving-average-sma-8713caf0d4ee | |
import requests | |
from datetime import datetime | |
# granularity: 60, 300, 900, 3600, 21600, 86400 | |
def cbpGetHistoricRates(market='BTC-GBP', granularity=86400, iso8601start='', iso8601end=''): | |
api = 'https://api.pro.coinbase.com/products/' + market + '/candles?granularity=' + \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# data: dictionary { 'dd/mm/yyy': price, 'dd/mm/yyyy': price, ... } | |
# num: range in the average calculation, normally 9 to 26 | |
def simpleMovingAverage(data, num): | |
if not isinstance(data, dict): | |
raise Exception('Dictionary input expected') | |
if not isinstance(num, int): | |
raise Exception('Integer input expected') | |
if num < 5 or num > 200: |