def find_fx(row, fx=None): # row.name is the date being passed # row['trade_currency'] is the base fx (the one where the trade was included) # Create an instance of PriceData: price = fx_price_ondate(current_app.settings['PORTFOLIO']['base_fx'], row['trade_currency'], row.name) return price
def btc_price(date_input): get_date = datetime.strptime(date_input, "%Y-%m-%d") # Create price object try: fx = fx_price_ondate('USD', current_app.fx['code'], get_date) price = price_ondate("BTC", get_date)['close'] * fx except Exception as e: logging.error("Not Found. Error: " + str(e)) price = 0 return (price)
def test_fx_price_ondate(self): date = '1/1/20' fx_price_ondate('USD', 'BRL', date) fx_price_ondate('EUR', 'BRL', date) fx_price_ondate('BRL', 'USD', date)