rotman interactive in python

To interact with Rotman Interactive in Python, you can use the rotman package. This package provides a set of tools and functionalities to connect to a Rotman Interactive simulation server and send trading orders.

Here are the steps to interact with Rotman Interactive in Python:

  1. Install the rotman package: You can install the package using pip by running the following command:

    main.py
    pip install rotman
    
    19 chars
    2 lines
  2. Import the required modules: In your Python script, import the necessary modules from the rotman package:

    main.py
    from rotman.api import RotmanAPI, Order
    
    40 chars
    2 lines
  3. Connect to the Rotman Interactive server: Instantiate a RotmanAPI object and connect to the Rotman Interactive server:

    main.py
    api = RotmanAPI()
    api.connect()
    
    32 chars
    3 lines
  4. Subscribe to market data: Subscribe to the market data that you want to receive in real-time by using the subscribe method of the RotmanAPI object. For example, to subscribe to Apple (AAPL) stock market data, use the following code:

    main.py
    api.subscribe('AAPL')
    
    22 chars
    2 lines
  5. Send trading orders: You can send trading orders using the send_order method of the RotmanAPI object. Here's an example of sending a buy order for 100 shares of Apple stock at a limit price of $150:

    main.py
    order = Order('AAPL', 'Buy', 100, 'Limit', price=150)
    api.send_order(order)
    
    76 chars
    3 lines

    You can customize the trading parameters according to your trading strategy.

  6. Monitor trading updates: Use the wait_for_new_updates method of the RotmanAPI object to wait for new updates from the Rotman Interactive server. This method blocks until a new update is received:

    main.py
    api.wait_for_new_updates()
    
    27 chars
    2 lines

    You can then retrieve the latest market data, trading account information, and other relevant information from the RotmanAPI object.

Remember to disconnect from the Rotman Interactive server when you are finished. Use the disconnect method of the RotmanAPI object:

main.py
api.disconnect()
17 chars
2 lines

Please note that you need valid credentials and access to a Rotman Interactive simulation server to connect and interact with it using the rotman package.

gistlibby LogSnag