Automate Trading Strategy w/ Python and Interactive Brokers
Budget: $250 – $750 USD
Main Input 1: pandas dataframe containing the target allocations of the portfolio, in percentage terms. The index of the dataframe contains the securities’ ISINs (and ‘Cash’) and the values of the dataframe add up to 1. Example:
%
FR0000121485 0.20
IT0003497168 0.30
AT0000A18XM4 0.40
Cash 0.10
Main Input 2: pandas dataframe containing the bracket orders to be associated with each of the positions. The index of the dataframe contains the securities’ ISINs. The dataframe has 2 columns: stop_loss and take_profit. These include the percentages below/above the entry price at which to place a stop_loss/take_profit order. Example:
stop_loss take_profit
FR0000121485 -0.10 0.30
IT0003497168 -0.20 None
AT0000A18XM4 None 0.40
Goal: rebalance the portfolio as close to the requested percentage allocation as possible, and implement the bracket orders requested, using the Interactive Brokers API
Requirements:
• Code must ideally be built in python and be properly documented, so that it can be modified
• Code must be able to run on both a paper trading account and a live trading account
• User must be able to choose the account ID of the live trading account (if more than one ID is associated with his account)
• Bracket orders (stop loss and take profit) must be linked to the quantity held in the security: if I sell 50 shares of company A, the quantity in the bracket orders must also decrease by 50 (and vice versa)
• Code should print portfolio positions before and after the rebalancing, along with any open orders
• User should be able to choose whether the income (e.g. dividends) is automatically reinvested (I believe IB has this feature but remains to be checked)
• Be mindful of currency conversion
%
FR0000121485 0.20
IT0003497168 0.30
AT0000A18XM4 0.40
Cash 0.10
Main Input 2: pandas dataframe containing the bracket orders to be associated with each of the positions. The index of the dataframe contains the securities’ ISINs. The dataframe has 2 columns: stop_loss and take_profit. These include the percentages below/above the entry price at which to place a stop_loss/take_profit order. Example:
stop_loss take_profit
FR0000121485 -0.10 0.30
IT0003497168 -0.20 None
AT0000A18XM4 None 0.40
Goal: rebalance the portfolio as close to the requested percentage allocation as possible, and implement the bracket orders requested, using the Interactive Brokers API
Requirements:
• Code must ideally be built in python and be properly documented, so that it can be modified
• Code must be able to run on both a paper trading account and a live trading account
• User must be able to choose the account ID of the live trading account (if more than one ID is associated with his account)
• Bracket orders (stop loss and take profit) must be linked to the quantity held in the security: if I sell 50 shares of company A, the quantity in the bracket orders must also decrease by 50 (and vice versa)
• Code should print portfolio positions before and after the rebalancing, along with any open orders
• User should be able to choose whether the income (e.g. dividends) is automatically reinvested (I believe IB has this feature but remains to be checked)
• Be mindful of currency conversion