execute
- class execute.execute.Execute(etrade)
Bases:
object- Description:
Execute trades
- Parameters:
etrade (pyetrade.ETradeAccounts, required) – Etrade API object
- Description:
Calculate shares to buy or sell
- Parameters:
weights (pandas.core.series.Series, required) – Weights of new portfolio
buying_power (float, required) – Buying power
reinvest (bool, optional) – Reinvest cash from short position, default is True
prints (bool, optional) – Prints, default is False
- Returns:
Shares to buy or sell
- Return type:
dict
- execute_trade(account_id_key, ticker, order_action, quantity, preview, prints=False)
- Description:
Helper function to execute trades
- Parameters:
account_id_key (str, required) – Account ID key
ticker (str, required) – Ticker
order_action (str, required) – Order action
quantity (int, required) – Quantity
preview (bool, optional) – Preview trades, default is True. If False, trades will be executed.
prints (bool, optional) – Prints, default is False
- Returns:
Trade response
- Return type:
dict
- execute_trades(current_portfolio, new_allocation, account_id_key, preview=True, prints=False)
- Description:
Execute trades
- Parameters:
current_portfolio (pandas.core.frame.DataFrame, required) – Current portfolio
new_allocation (pandas.core.series.Series, required) – New allocation
account_id_key (str, required) – Account ID key
preview (bool, optional) – Preview trades, default is True. If False, trades will be executed.
prints (bool, optional) – Prints, default is False
- Returns:
Trade responses
- Return type:
dict
- generate_trades(account_id_key, symbol, order_action, quantity, price_type='MARKET', order_term='GOOD_FOR_DAY', market_session='REGULAR', preview=True, prints=False)
- Description:
Generate trades. If preview is True, trades will be previewed. If False, trades will be executed.
- Parameters:
account_id_key (str, required) – Account ID key
symbol (str, required) – Ticker
order_action (str, required) – Order action
quantity (int, required) – Quantity
price_type (str, optional) – Price type, default is ‘MARKET’.
order_term (str, optional) – Order term, default is ‘GOOD_FOR_DAY’
market_session (str, optional) – Market session, default is ‘REGULAR’
preview (bool, optional) – Preview trades, default is True. If False, trades will be executed.
prints (bool, optional) – Prints, default is False
- Returns:
Trade response
- Return type:
dict