Skip to content

Commit

Permalink
stock form code updated
Browse files Browse the repository at this point in the history
  • Loading branch information
YogeshUpdhyay committed May 16, 2021
1 parent 1366c1c commit b70fb30
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
9 changes: 8 additions & 1 deletion app/dashboard/api.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
from flask import Blueprint, jsonify, request

from app.utils.stock import Stock

bp = Blueprint("api", __name__, url_prefix="/api/v1")

stock = Stock()

@bp.route("/stockdetail", methods=["GET", "POST"])
def stock_detail():
print(request.data)
ticker = request.form["ticker"]
print(ticker)
data = stock.get_data("NSE:{}".format(ticker))
print(data)
return jsonify(msg="Success")

5 changes: 4 additions & 1 deletion app/utils/stock.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,16 @@ def get_data(self, symbol, size = "full", function = "TIME_SERIES_DAILY_ADJUSTED

# making the api request and parsing the data
response = requests.get(self.base_url, params=params)
print(response)
if response.status_code == 200:
data = json.loads(response.data)
return response.data
return data
else:
print(response.status_code)
return None

def concat_data(self, data, start_date, end_date) -> dict:
# parsing data based on the satrt date and end date
parsed_data = []
for day, price in data["Time Series (Daily)"].items():
date = datetime(day)
Expand Down

0 comments on commit b70fb30

Please sign in to comment.