-
-
Notifications
You must be signed in to change notification settings - Fork 20
Offset Sold Puts/Calls (Sourcery refactored) #147
Conversation
618ab0a
to
2ef32ab
Compare
2ef32ab
to
5b2bb2f
Compare
"Failed to get Account {}. Attempt #{}".format( | ||
self.account_number, attempt | ||
) | ||
f"Failed to get Account {self.account_number}. Attempt #{attempt}" | ||
) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function TdaBroker.get_account
refactored with the following changes:
- Replace call to format with f-string. (
use-fstring-for-formatting
)
logger.exception( | ||
"Failed to read order {}.".format(str(request.orderid)) | ||
) | ||
logger.exception(f"Failed to read order {str(request.orderid)}.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function TdaBroker.get_order
refactored with the following changes:
- Replace call to format with f-string. (
use-fstring-for-formatting
)
logger.exception("Chain Validation Failed. {}".format(optionchainobj)) | ||
logger.exception(f"Chain Validation Failed. {optionchainobj}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function TdaBroker.get_option_chain
refactored with the following changes:
- Replace call to format with f-string. (
use-fstring-for-formatting
)
logger.exception( | ||
"Failed to get quotes. Attempt #{}".format(attempt), | ||
) | ||
logger.exception(f"Failed to get quotes. Attempt #{attempt}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function TdaBroker.get_quote
refactored with the following changes:
- Replace call to format with f-string. (
use-fstring-for-formatting
)
"Failed to get market hours for {} on {}. Attempt #{}".format( | ||
markets, request.datetime, attempt | ||
), | ||
f"Failed to get market hours for {markets} on {request.datetime}. Attempt #{attempt}" | ||
) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function TdaBroker.get_market_hours
refactored with the following changes:
- Replace call to format with f-string. (
use-fstring-for-formatting
)
self.strategy_id, int(order_id) | ||
self.strategy_id, order_id | ||
) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function SingleByDeltaStrategy.cancel_order
refactored with the following changes:
- Remove unnecessary casts to int, str and float (
remove-unnecessary-cast
)
best_quantity = int(0) | ||
best_quantity = 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function SingleByDeltaStrategy.get_best_strike_and_quantity
refactored with the following changes:
- Remove unnecessary casts to int, str and float (
remove-unnecessary-cast
)
# Check if should be sleeping | ||
if now < self.sleepuntil: | ||
logger.debug("Markets Closed. Sleeping until {}".format(self.sleepuntil)) | ||
logger.debug(f"Markets Closed. Sleeping until {self.sleepuntil}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function SpreadsByDeltaStrategy.process_strategy
refactored with the following changes:
- Replace call to format with f-string. (
use-fstring-for-formatting
)
"Markets are closed until {}. Sleeping until {}".format( | ||
nextmarketsession.start, | ||
self.sleepuntil, | ||
) | ||
f"Markets are closed until {nextmarketsession.start}. Sleeping until {self.sleepuntil}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function SpreadsByDeltaStrategy.process_pre_market
refactored with the following changes:
- Replace call to format with f-string. (
use-fstring-for-formatting
)
logger.info( | ||
"Short Strike: {} Long Strike: {} BuyingPower: {} LiquidationValue: {} MaxLoss: {} BalanceToRisk: {} RemainingBalance: {} TradeSize: {} ".format( | ||
shortstrike, | ||
longstrike, | ||
account_balance.buyingpower, | ||
account_balance.liquidationvalue, | ||
max_loss, | ||
balance_to_risk, | ||
remainingbalance, | ||
trade_size, | ||
) | ||
f"Short Strike: {shortstrike} Long Strike: {longstrike} BuyingPower: {account_balance.buyingpower} LiquidationValue: {account_balance.liquidationvalue} MaxLoss: {max_loss} BalanceToRisk: {balance_to_risk} RemainingBalance: {remainingbalance} TradeSize: {trade_size} " | ||
) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function SpreadsByDeltaStrategy.calculate_order_quantity
refactored with the following changes:
- Replace call to format with f-string. (
use-fstring-for-formatting
)
Sourcery Code Quality Report❌ Merging this PR will decrease code quality in the affected files by 0.23%.
Here are some functions in these files that still need a tune-up:
Legend and ExplanationThe emojis denote the absolute quality of the code:
The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request. Please see our documentation here for details on how these metrics are calculated. We are actively working on this report - lots more documentation and extra metrics to come! Help us improve this quality report! |
Pull Request #142 refactored by Sourcery.
If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.
NOTE: As code is pushed to the original Pull Request, Sourcery will
re-run and update (force-push) this Pull Request with new refactorings as
necessary. If Sourcery finds no refactorings at any point, this Pull Request
will be closed automatically.
See our documentation here.
Run Sourcery locally
Reduce the feedback loop during development by using the Sourcery editor plugin:
Review changes via command line
To manually merge these changes, make sure you're on the
Wide-Spreads
branch, then run:Help us improve this pull request!