async def get_something_old(*,
                            ticker: str,
                            indicator: str,
                            q: Optional[str] = None):
    print(f"indicator: {indicator}, ticker: {ticker}")

    # date params format: YYYY/MM/DD
    start_date = date.today() - timedelta(days=365)
    start_date = start_date.strftime("%Y/%m/%d")

    talib_inputs = ta_calcs.get_ohlc_values(ticker, start_date)

    indicator_values = ta_calcs.get_indicator_values(indicator, talib_inputs)

    talib_inputs = fnc.pd_series_to_list(talib_inputs)

    str_dates = fnc.date_converter(talib_inputs['date'])

    if q:
        print({"q": q})

    return_json = {}
    return_json['ticker'] = ticker
    return_json['name'] = fnc.get_name(ticker)
    return_json[f'{indicator}'] = indicator_values
    return_json['date'] = str_dates

    # return_json['date'] = str_dates

    # return json.dumps(return_json)
    json_compatible_item_data = jsonable_encoder(return_json)
    return JSONResponse(content=json_compatible_item_data)
Esempio n. 2
0
async def get_year_today_prices(ticker: str):
    data = ohlc.get_ohlc_year_today(ticker)

    return_json = {}
    return_json['ticker'] = ticker
    return_json['name'] = fnc.get_name(ticker)
    return_json['data'] = data

    return jsonable_encoder(return_json)
Esempio n. 3
0
def get_year_today_prices():
    ticker = request.args.get('ticker')

    data = ohlc.get_ohlc_year_today(ticker)

    return_json = {}
    return_json['ticker'] = ticker
    return_json['name'] = fnc.get_name(ticker)
    return_json['data'] = data

    return jsonify(return_json)
Esempio n. 4
0
async def get_price_between(ticker: str, start_date: str, end_date: str):
    # date params format: YYYY/MM/DD

    data = ohlc.get_ohlc_between(ticker, start_date, end_date)

    return_json = {}
    return_json['ticker'] = ticker
    return_json['name'] = fnc.get_name(ticker)
    return_json['data'] = data

    return jsonable_encoder(return_json)
Esempio n. 5
0
def get_price_between():
    ticker = request.args.get('ticker')
    start_date = request.args.get('start_date')
    end_date = request.args.get('end_date')
    data = ohlc.get_ohlc_between(ticker, start_date, end_date)

    return_json = {}
    return_json['ticker'] = ticker
    return_json['name'] = fnc.get_name(ticker)
    return_json['data'] = data

    return jsonify(return_json)
async def get_something(*,
                        ticker: str,
                        indicator: str,
                        q: Optional[str] = None):
    #print(f"indicator: {indicator}, ticker: {ticker}")

    # date params format: YYYY/MM/DD
    start_date = date.today() - timedelta(days=365)
    #start_date = start_date.strftime("%Y/%m/%d")
    start_date = start_date.strftime("%m/%d/%Y")
    #print("start_date")
    #print(start_date)

    talib_inputs = ta_calcs.get_ohlc_values(ticker, start_date)

    indicator_values = ta_calcs.get_indicator_values(indicator, talib_inputs)

    talib_inputs = fnc.pd_series_to_list(talib_inputs)

    print(type(talib_inputs))
    # talib_inputs['price'] = indicator_values['price']

    return_json = {}
    return_json['ticker'] = ticker
    return_json['name'] = fnc.get_name(ticker)
    return_json['indicator'] = indicator
    return_json['values'] = ta_calcs.lista[indicator]
    # candlestick
    #return_json['data'] = talib_inputs
    return_json['data'] = indicator_values

    # return_json[f'{indicator}'] = indicator_values
    return_json['date'] = fnc.date_converter(talib_inputs['date'])
    talib_inputs.pop("date")
    # return_json['date'] = str_dates

    # return json.dumps(return_json)
    if q:
        return_json.update({"q": q})
    json_compatible_item_data = jsonable_encoder(return_json)
    return JSONResponse(content=json_compatible_item_data)
Esempio n. 7
0
def get_adx():
    ticker = request.args.get('ticker')
    indicator = request.args.get('indicator')
    print(f"indicator: {indicator}, ticker: {ticker}")

    # date params format: YYYY/MM/DD
    start_date = date.today() - timedelta(days=365)
    start_date = start_date.strftime("%Y/%m/%d")

    talib_inputs = ta_calcs.get_ohlc_values(ticker, start_date)

    indicator_values = ta_calcs.get_indicator_values(indicator, talib_inputs)

    talib_inputs = fnc.pd_series_to_list(talib_inputs)

    str_dates = fnc.date_converter(talib_inputs['date'])

    return_json = {}
    return_json['ticker'] = ticker
    return_json['name'] = fnc.get_name(ticker)
    return_json[f'{indicator}'] = indicator_values
    return_json['date'] = str_dates

    return jsonify(return_json)