Skip to content

Library to fetch and parse realtime Forex quotes and convert currencies

License

Notifications You must be signed in to change notification settings

1Forge/python-forex-quotes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

python_forex_quotes

python_forex_quotes is a Python Library for fetching realtime forex quotes

Table of Contents

Requirements

Installation

pip install python_forex_quotes

Usage

Instantiate the client

import python_forex_quotes

#You can get an API key for free at 1forge.com
client = python_forex_quotes.ForexDataClient('YOUR_API_KEY')

Get the list of available symbols:

import python_forex_quotes
client = python_forex_quotes.ForexDataClient('YOUR_API_KEY')

print client.getSymbols()

Get quotes for specified symbols:

import python_forex_quotes
client = python_forex_quotes.ForexDataClient('YOUR_API_KEY')

print client.getQuotes(['EUR/USD', 'GBP/JPY'])

Convert from one currency to another:

import python_forex_quotes
client = python_forex_quotes.ForexDataClient('YOUR_API_KEY')

print client.convert('EUR', 'USD', 100)

Check if the market is open:

import python_forex_quotes
client = python_forex_quotes.ForexDataClient('YOUR_API_KEY')

if client.marketIsOpen() == True:
    print "Market is open!"

Check your usage / quota limit:

import python_forex_quotes
client = python_forex_quotes.ForexDataClient('YOUR_API_KEY')

print client.quota()

Websocket

Subscribe to all the pairs:

import python_forex_quotes

def onUpdate(value):
    print(value)

def onMessage(value):
    print(value)

def onConnect():
    client.subscribeToAll()

client = python_forex_quotes.ForexDataClient('YOUR_API_KEY')
client.onUpdate(onUpdate)
client.onConnect(onConnect)
client.onMessage(onMessage)
client.connect()

Subscribe to certain the pairs:

def onConnect():
    client.subscribeTo("USD/CHF")
    client.subscribeTo(["EUR/USD", "BTC/USD"])

Unsubscribe from all the pairs:

def onConnect():
    client.unsubscribeFromAll()

Unsubscribe from certain the pairs:

def onConnect():
    client.unsubscribeFrom("USD/CHF")
    client.unsubscribeFrom(["EUR/USD", "BTC/USD"])

Contributing

Thank you for considering contributing! Any issues, bug fixes, suggestions, improvements or help in any other way is always appreciated. Please feel free to open an issue or create a pull request.

Support and Contact

Please contact me at [email protected] if you have any questions or requests.

License and Terms

This library is provided without warranty under the MIT license.

About

Library to fetch and parse realtime Forex quotes and convert currencies

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages