from datetime import datetime from pathlib import Path import requests import os from pricing_engine.engine import apikey from connections import tor_request import pandas as pd from warden_modules import current_path from warden_decorators import MWT from flask import flash # docs # https://www.alphavantage.co/documentation/ api = apikey('alphavantage', True) @MWT(timeout=10) def realtime(ticker, fx='USD', function='CURRENCY_EXCHANGE_RATE', parsed=True): if function == 'CURRENCY_EXCHANGE_RATE': # Request data globalURL = 'https://www.alphavantage.co/query?function=' + function globalURL += '&from_currency=' + ticker globalURL += '&to_currency=' + fx globalURL += '&apikey=' + api # No need for any API calls to return 1 :) if ticker == fx: return ({ 'Realtime Currency Exchange Rate': { '1. From_Currency Code': ticker, '2. From_Currency Name': ticker,
from datetime import datetime import requests from pricing_engine.engine import apikey from connections import tor_request import pandas as pd # Docs # https://financialmodelingprep.com/developer/docs/#Stock-Price api = apikey('fmp', True) def realtime(ticker, parsed=True): ''' Gets realtime prices using FMP Only Stocks are accepted Result: [ { "symbol": "AAPL", "price": 121.26000000, "volume": 164560045 } ] Limit reached Message: {'Error Message': 'Limit Reach . Please upgrade your plan or visit our documentation for more details at https://financialmodelingprep.com/developer/docs/pricing'}
def test_td_found_api(self): config = load_config() self.assertEqual(config.has_option('API', 'twelvedata'), True) api_key = apikey('twelvedata', True) self.assertNotEqual(api_key, None)
from datetime import datetime import logging import requests from pricing_engine.engine import apikey from connections import tor_request import pandas as pd from warden_decorators import MWT # Docs # https://min-api.cryptocompare.com/documentation api = apikey('cryptocompare', False) # @MWT(timeout=10) def realtime(ticker, fxs='USD', parsed=True): ''' Gets realtime prices using CryptoCompare Only Cryptocurrencies are accepted Result: {'BTC': 0.03041, 'USD': 1354.75, 'GBP': 975.18} :param str ticker: Ticker or Symbol :param str fxs: a string of a single currency or comma separated currencies. ex: 'USD' or 'USD,EUR' :return: Realtime price data :raises Exception: if Tor request returns a 403 (not authorized) ''' # Request data globalURL = 'https://min-api.cryptocompare.com/data/price?fsym=' + ticker globalURL += '&tsyms=' + fxs
def test_fmp_found_api(self): config = load_config() self.assertEqual(config.has_option('API', 'fmp'), True) api_key = apikey('fmp', True) self.assertNotEqual(api_key, None)
def test_cc_found_api(self): api_key = apikey('cryptocompare', True) self.assertNotEqual(api_key, None)
def test_aa_found_api(self): config = load_config() self.assertEqual(config.has_option('API', 'alphavantage'), True) api_key = apikey('alphavantage', True) self.assertNotEqual(api_key, None)
from datetime import datetime import requests from pricing_engine.engine import apikey from connections import tor_request import pandas as pd # Docs # https://twelvedata.com/docs api = apikey('twelvedata', True) def realtime(ticker, parsed=True): ''' Gets realtime prices using TwelveData Only Stocks are accepted Result: { "symbol": "GBTC", "name": "Grayscale Bitcoin Trust (BTC)", "exchange": "OTC", "currency": "USD", "datetime": "2021-03-01", "open": "46.18000", "high": "47.07000", "low": "45.70000", "close": "46.20000", "volume": "7298247", "previous_close": "43.20000", "change": "3.00000",
def test_cc_found_api(self): config = load_config() self.assertEqual(config.has_option('API', 'cryptocompare'), True) api_key = apikey('cryptocompare', True) self.assertNotEqual(api_key, None)