Skip to content

Commit

Permalink
tinkering
Browse files Browse the repository at this point in the history
  • Loading branch information
Pfed-prog committed Oct 3, 2022
1 parent 14b4240 commit df177d1
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 23 deletions.
Empty file added .env
Empty file.
19 changes: 0 additions & 19 deletions api/index.py

This file was deleted.

51 changes: 48 additions & 3 deletions index.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,52 @@
from flask import Flask, Response
"""nonempty"""
import os
import json
import requests
from flask import Flask, Response, request, jsonify

import pandas as pd
import numpy as np
#from statsmodels.tsa.arima.model import ARIMA


app = Flask(__name__)

@app.route('/', defaults={'path': ''})
URL ='https://api.thegraph.com/subgraphs/name/uniswap/uniswap-v3'

headers = {'Content-Type': 'application/json',
'Authorization': os.environ.get("API_KEY")}

URL ='https://api.thegraph.com/subgraphs/name/uniswap/uniswap-v3'

@app.route("/", methods=["GET","POST"], defaults={'path': ''})
def home():
"""prediction"""
if request.args.get('f'):
f = int(request.args.get('f'))
else:
f=15
if request.args.get('a'):
address = request.args.get('a')
else:
address = "0x1f9840a85d5af5bf1d1762f925bdaddc4201f984"

query = """
{token (id: "%s"){tokenDayData { priceUSD date } } }
""" % address

r = requests.post(URL, json={'query': query})
json_data = json.loads(r.text)
df_data = json_data['data']['token']['tokenDayData']
df = pd.DataFrame(df_data)

df.priceUSD = df.priceUSD.replace(0, np.nan).dropna()
df.priceUSD = df.priceUSD.astype(float)

last = df.date.iloc[-1:].values[0]
timestep = df.date.iloc[-1:].values[0]-df.date.iloc[-2:-1].values[0]

return jsonify({ 'last_date': str(last), 'timestep': str(timestep)})
@app.route('/<path:path>')
def catch_all(path):
return Response("<h1>Flask</h1><p>You visited: /%s</p>" % (path), mimetype="text/html")
"""check"""
return Response("<h1>Flask</h1><p>You visited: /%s</p>" % (path), mimetype="text/html")
16 changes: 15 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
certifi==2022.9.24
charset-normalizer==2.1.1
click==8.1.3
Flask==2.2.2
idna==3.4
itsdangerous==2.1.2
Jinja2==3.1.2
MarkupSafe==2.1.1
numpy==1.23.3
packaging==21.3
pandas==1.5.0
patsy==0.5.2
pyparsing==3.0.9
python-dateutil==2.8.2
pytz==2022.4
requests==2.28.1
scipy==1.9.1
six==1.16.0
statsmodels==0.13.2
urllib3==1.26.12
Werkzeug==2.2.2
cowpy==1.0.3

0 comments on commit df177d1

Please sign in to comment.