How does a Python wrapper simplify the process of coding an algo?

Python is one of many programming languages used by algo traders to create a trading strategy. A Python wrapper simplifies a function into a much shorter expression that can be used repeatedly. When programming a trading strategy, one may need to use the same function or series of functions repeatedly, for example to authenticate login credentials, to pull live data, or to place a trade.

Fxcmpy can easily be installed using pip. Once installed, the user will need to obtain an API token for authentication.Once obtained, connection to the REST API can be established in a single line of code:

con = fxcmpy.fxcmpy(config_file='fxcm.cfg', sever='demo')

Once connected, one can begin using the fxcmpy Python wrapper to pull historical and live prices, set entry orders, execute trades and more. Historical data can be pulled in the periods 'm1', 'm5', 'm15', 'm30', 'H1', 'H2', 'H3', 'H4', 'H6', 'H8′,'D1', 'W1' or 'M1' using a single line of code. For example, entering the following line of code will output the high, low, open and close price of the EUR/USD for the past 30 one-minute candles.

data = con.get_candles('EUR/USD', period = 'm1', number = 30)

To create a basic market order, you will provide the instrument and the size of the order (in micro lots) as parameters to either the create_market_sell_order() or create_market_buy_order() methods:

con.create_market_buy_order('USD/JPY', 10)

These are just some of the commands available for use.

Russell Shor

Russell Shor

Senior Market Specialist

Russell Shor (MSTA, CFTe, MFTA) is a Senior Market Specialist at FXCM. He joined the firm in October 2017 and has an Honours Degree in Economics from the University of South Africa and holds the coveted Certified Financial Technician and Master of Financial Technical Analysis qualifications from the International Federation…

View Profile

Disclosure

Any opinions, news, research, analyses, prices, other information, or links to third-party sites contained on this website are provided on an "as-is" basis, as general market commentary and do not constitute investment advice. The market commentary has not been prepared in accordance with legal requirements designed to promote the independence of investment research, and it is therefore not subject to any prohibition on dealing ahead of dissemination. Although this commentary is not produced by an independent source, Friedberg Direct, FXCM or its affiliates takes all sufficient steps to eliminate or prevent any conflicts of interests arising out of the production and dissemination of this communication. The employees of Friedberg Direct and FXCM commit to acting in the clients' best interests and represent their views without misleading, deceiving, or otherwise impairing the clients' ability to make informed investment decisions. For more information about the Friedberg Direct's internal organizational and administrative arrangements for the prevention of conflicts, please refer to the Firms' Managing Conflicts Policy. Please ensure that you read and understand our Full Disclaimer and Liability provision concerning the foregoing Information, which can be accessed here.**

Order Execution Only

Order Execution Only

Regulatory Documents:
IIROC Brochure: How Can I Get My Money Back, How IIROC Protects Investors, IIROC Complaints Brochure, CIPF Brochure, CIPF Coverage Policy, IIROC Order Execution Only Bulletin, Conflict Disclosure Statement

The relationship between Friedberg Direct and FXCM was formed with the purpose to allow Canadian residents access to FXCM's suite of products, while maintaining their accounts with a regulated Canadian firm. All accounts are opened by and held with Friedberg Direct, a division of Friedberg Mercantile Group Ltd., a member of the Investment Industry Regulatory Organization of Canada (IIROC). Friedberg customer accounts are protected by the Canadian Investor Protection Fund within specified limits. A brochure describing the nature and limits of coverage is available upon request or at www.cipf.ca.