Comments (2)
- Modify
CurrencyRates
in theforex_python.converter
module:
import requests
from forex_python.converter import CurrencyRates as BaseCurrencyRates
class CurrencyRates(BaseCurrencyRates):
def __init__(self, session=None, proxies=None, verify_ssl=True):
super().__init__()
if session is None:
session = requests.Session()
if proxies is not None:
session.proxies = proxies
session.verify = verify_ssl
self.session = session
# ... rest of the class methods ...
# This import ensures that the class is available when the module is imported
CurrencyRates()
- Usage:
from forex_python.converter import CurrencyRates
# Create a session with proxy settings and SSL verification turned off
proxies = {
'http': 'http://proxy.example.com:8080',
'https': 'https://proxy.example.com:8080'
}
currency_rates = CurrencyRates(proxies=proxies, verify_ssl=False)
# Now you can use the `currency_rates` object for your API calls
Keep in mind that this approach involves modifying the library's code directly. If you choose to go this route, make sure to take care and consider the impact on future library updates.
Alternatively, if modifying the library directly isn't desired, you could create a wrapper class that inherits from CurrencyRates
and adds the desired functionality. This would allow you to achieve the desired behavior without modifying the original library code.
from forex-python.
- Modify
CurrencyRates
in theforex_python.converter
module:import requests from forex_python.converter import CurrencyRates as BaseCurrencyRates class CurrencyRates(BaseCurrencyRates): def __init__(self, session=None, proxies=None, verify_ssl=True): super().__init__() if session is None: session = requests.Session() if proxies is not None: session.proxies = proxies session.verify = verify_ssl self.session = session # ... rest of the class methods ... # This import ensures that the class is available when the module is imported CurrencyRates()
- Usage:
from forex_python.converter import CurrencyRates # Create a session with proxy settings and SSL verification turned off proxies = { 'http': 'http://proxy.example.com:8080', 'https': 'https://proxy.example.com:8080' } currency_rates = CurrencyRates(proxies=proxies, verify_ssl=False) # Now you can use the `currency_rates` object for your API callsKeep in mind that this approach involves modifying the library's code directly. If you choose to go this route, make sure to take care and consider the impact on future library updates.
Alternatively, if modifying the library directly isn't desired, you could create a wrapper class that inherits from
CurrencyRates
and adds the desired functionality. This would allow you to achieve the desired behavior without modifying the original library code.
Great workaround, thanks!
from forex-python.
Related Issues (20)
- CurrencySources not ready (Not working) HOT 1
- SSL Certificate Expired HOT 7
- Currency Rates Source Not Ready HOT 2
- doesn't return any currency rates after 2023-04-14 HOT 3
- RatesNotAvailableError: Currency Rates Source Not Ready HOT 3
- api down
- CurrencyRates conversion is not correct. HOT 2
- conversion USD to PKR
- get historical ohlc data HOT 1
- TheForexapi website is down HOT 2
- No new data after 09-08-2023
- Getting wrong values for conversion rate EUR to USD and GBP to USD using forex_python package HOT 3
- SRY
- RatesNotAvailableError for the past couple of days HOT 2
- test.py faling
- theforexapi.com is not working HOT 19
- Historical BTC rates intermittently available from 2022-05-18 and then not available at all from 2022-07-10 HOT 1
- CAD -> USD rate stuck?
- Forex python is not available anymore HOT 4
- raise RatesNotAvailableError("Currency Rates Source Unavailable.") forex_python.converter.RatesNotAvailableError: Currency Rates Source Unavailable. HOT 11
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from forex-python.