alpaca-trade-api-python icon indicating copy to clipboard operation
alpaca-trade-api-python copied to clipboard

Use another augmented assignment statement

Open elfring opened this issue 4 years ago • 0 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Is your feature request related to a problem? Please describe.

:eyes: Some source code analysis tools can help to find opportunities for improving software components. :thought_balloon: I propose to increase the usage of augmented assignment statements accordingly.

Describe the solution you'd like.

diff --git a/examples/martingale.py b/examples/martingale.py
index dcbcf7a..f4ffcfa 100644
--- a/examples/martingale.py
+++ b/examples/martingale.py
@@ -176,7 +176,7 @@ class MartingaleTrader(object):
                     target_value = total_buying_power - self.last_price
                 target_qty = int(target_value / self.last_price)
                 if self.streak_increasing:
-                    target_qty = target_qty * -1
+                    target_qty *= -1
                 self.send_order(target_qty)
         # Update our account balance
         self.equity = float(self.api.get_account().equity)

Describe an alternate solution.

No response

Anything else? (Additional Context)

No response

elfring avatar Nov 02 '21 08:11 elfring