Skip to content

Commit

Permalink
Add more helpful calculations to preview output
Browse files Browse the repository at this point in the history
This adds another preview output: dividing the commission by total
contract multiplier to get a basic "price the contract must change to
cover the commission" (and also provide (* 2) to cover open+closing
commission)
  • Loading branch information
mattsta committed Nov 25, 2023
1 parent 45faa48 commit 0895fc1
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions icli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -915,6 +915,21 @@ async def placeOrderForContract(
(trade.minCommission) / order.totalQuantity,
(trade.maxCommission) / order.totalQuantity,
)

if multiplier > 1:
# (Basically: how much must the underlying change in price for you to pay off
# the commission for this order (note: probably 2x this to cover
# both sides of the commission to exit.)
tcmin = trade.minCommission / order.totalQuantity / multiplier
tcmax = trade.maxCommission / order.totalQuantity / multiplier
logger.info(
"[{}] PREVIEW COMMISSION PER UNDERLYING: ${:.4f} to ${:.4f} (2x: ${:.4f} to ${:.4f})",
desc,
tcmin,
tcmax,
2 * tcmin,
2 * tcmax,
)
elif isset(trade.commission):
# futures contracts and index options contracts have fixed priced commissions so
# they don't provide a min/max range, it's just one guaranteed value.
Expand All @@ -924,6 +939,15 @@ async def placeOrderForContract(
(trade.commission) / order.totalQuantity,
)

tc = trade.commission / order.totalQuantity / multiplier
if multiplier > 1:
logger.info(
"[{}] PREVIEW COMMISSION PER UNDERLYING: ${:.4f} (2x: ${:.4f})",
desc,
tc,
2 * tc,
)

# (if trade isn't valid, trade is an empty list, so only print valid objects...)
if trade:
# sigh, these are strings of course.
Expand Down

0 comments on commit 0895fc1

Please sign in to comment.