Rithmic Python API Trading App
Python Rithmic API Trading App
- This is a minimum viable product (MVP).
- It provides access to the following:
- You must provide your own trading strategy and execution logic. You can place it in the
runstrategy()function inrithmictrading_app.py. - The app is configured to place market orders only.
- The app is configured to execute the strategy placeholder every 5-minutes.
Prequisites
- You must have either a Rithmic Paper Trading or Rithmic Live account, NOT A TEST ACCOUNT.
- You must pass Rithmic's conformance testing.
- After passing conformance testing, Rithmic will send you the following:
A four-character prefix
Rithmic will send you a four-character prefix.
- In
mdstream.py,pospnlstream.py,histbarsohlc.py, andplaceorders.py, find the following variables:
rq.app_name
* Update its value by replacing CHANGE_ME with the prefix issued by Rithmic.
Proto Files
In the library imports section of the Python files (mdstream.py, pospnlstream.py, histbarsohlc.py, and placeorders.py) you will see references to _pb2 files. You must get those from Rithmic and drop them in the protobuf directory.
SSL Cert File
The application files reference the rithmicsslcertauthparams file. You should have received that file from Rithmic. Drop your copy in the root directory.
URI
After you pass conformance testing, Rithmic will send you the URI to access its system. In the rithmictradingapp.py file, go to the line uri = 'CHANGE_ME' and assign the variable with the URI supplied by Rithmic.
Installation
Download the repo to your hard drive.
Start App
After downloading the repo, cd to pythonrithmictrading_app.
Run the following command:
python rithmictradingapp.py [username] [password] [exchange] [contract symbol] [contact qty] [FCM] [IB]
For example, if your Rithmic credentials are 00000000-DEMO/password123 and you want the trading app to monitor the Crude Oil market and to trade only one quantity of the December 2024 contract, through your IB (e.g., Ironbeam) and FCM (e.g., Ironbeam), then you would run the following command:
python rithmictradingapp.py 00000000-DEMO password123 NYMEX CLZ4 1 Ironbeam Ironbeam
After starting the trading app, you will see a series of INFO messages indicating that the app is receiving tick data, monitoring PnL and position data, and is executing the strategy placeholder every five minutes.
Stop App
To stop the app, issue a KeyboardInterrupt, Ctrl+C.
Live Trading
After thoroughly testing your trading strategy and execution logic, if you wish to trade live, do the following:
- In
rithmictradingapp.py, find the variablesystem_name. - Change its value from
Rithmic Paper TradingtoRithmic 01.