How to get FOREX data live-streaming in python?

Question:

I used this github code for getting FOREX data live-streaming, but it produced NAN values in all columns.

Can anyone help me to get live FOREX data in python?

Your help will be appreciated, thanks in advance

Asked By: Sarath_Mj

||

Answers:

Can you post your output / error?

Is it like the following?

           Date  Bid  Bid_point  Ask  Ask_point  High  Low  Open
Symbol
not authorized  NaT  NaN        NaN  NaN        NaN   NaN  NaN   NaN

If so,
are you passing username and password to the script?

Here is the help provided from that very script:

python3 truefx_api.py --help
Usage: run.py [OPTIONS]

Options:
--symbols TEXT                  Symbols list (separated with ','
--username TEXT                 TrueFX username
--password TEXT                 TrueFX password
--force-unregistered / --no-force-unregistered
                                Force unregistered
--expire_after TEXT             Cache expiration (-1: no cache, 0: no
                                expiration, 00:15:00.0: expiration delay)
--help                          Show this message and exit.

UPDATE:
In response to OP’s latest comment:

The referenced doc http://www.truefx.com/dev/data/TrueFX_MarketDataWebAPI_DeveloperGuide.pdf contains an EXAMPLE username and password. You cannot use those. You need to signup and get a real username and password.

Answered By: ChuckB

Step No. 1:

Contact the API-provider ( TrueFX in this case )
and
contract with them the API-usage ( Terms & Conditions apply ).

Result [1] : you will receive valid user credentials for your use
{
USERNAME: <_a_unique_your_username_contracted_with_TrueFX_>,
PASSWORD: <_a_unique_your_password_contracted_with_TrueFX_>
}


Next No.2:

Having received this “key” to using theirs API, your CLI launch may start like this:

python3 truefx_api.py --symbols EUR/USD --username <_a_unique_your_username_contracted_with_TrueFX_> --password <_a_unique_your_password_contracted_with_TrueFX_>

Result [2] : you will receive API-services, given
a) you have correctly provided credentials obtained in Step No.1 exactly, 1:1, without a single typo on the command line
or
b) you have correctly setup so called environment variables TRUEFX_USERNAME and TRUEFX_PASSWORD ( kindly consult your system documentation or contact the system administrator in case such setup is restricted but to the owner of the localhost administrator’s privilege )


Next No.3:

Since this moment,
a) you may enjoy the contracted API-services,
or
b) you might have to claim API-services failures on the provider-side ( TrueFX, for this case ) given some problems arise, so as to have such API-service failure fixed & for due remedies to take place and you move back to a)

Result [3] : Sun is shining and the World works as it was assumed to have to.

Answered By: user3666197

Disclaimer: I am one of the developers for Polygon.io

100% Free Forex/Currency Trades/Quotes streams. We use NATS.io as the message broker which has clients for Python and almost every other language.

  • Our latency is usually less than 200ms
  • Prices are to the 5 decimal digits
  • 54 Tracked forex pairs

Here is the code sample for Python 3.x : https://github.com/Polygon-io/client-examples/tree/master/python

Polygon.io – Free real time forex stream

We also have RESTful APIs for current/historic prices.

Answered By: Quinton Pike

The script was written by Nematillo Ochilov.
Run the script at https://colab.research.google.com/

#! pip install yfinance
#! pip install fbprophet

import yfinance
import pandas as pd
import datetime
from fbprophet import Prophet


data = yfinance.download ('BTC-USD', strat = '2020-12-01', # machine learning period
                          end = datetime.datetime.today (), interval = '1d') # period interval unit (day)
df = pd.DataFrame ()
df ['y'] = data ['Close']
df ['ds'] = data.index
model = Prophet (daily_seasonality = True)
model.fit (df)
future = model.make_future_dataframe (periods = 730) # future prediction period
result = model.predict (future)
model.plot (result)

From this script you can get the history of stocks, metals, currency pairs and cryptocurrencies and predict their future.

If you are new to programming, this video will help you to run the script https://youtu.be/qTDn149P9-o

Answered By: Nematillo Ochilov
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.