This repository was archived by the owner on Jan 12, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 522
This repository was archived by the owner on Jan 12, 2024. It is now read-only.
Increase the usage of augmented assignment statements #176
Copy link
Copy link
Open
Labels
Description
👀 Some source code analysis tools can help to find opportunities for improving software components.
💭 I propose to increase the usage of augmented assignment statements accordingly.
diff --git a/qtpylib/broker.py b/qtpylib/broker.py
index 8c3461a..54cdade 100644
--- a/qtpylib/broker.py
+++ b/qtpylib/broker.py
@@ -698,7 +698,7 @@ class Broker():
self.orders.recent[orderId]['price'] = 0
# add orderId / ttl to (auto-adds to history)
- expiry = expiry * 1000 if expiry > 0 else 60000 # 1min
+ expiry *= 1000 if expiry > 0 else 60000 # 1min
self._update_pending_order(symbol, orderId, expiry, order_quantity)
time.sleep(0.1)
diff --git a/qtpylib/futures.py b/qtpylib/futures.py
index 773034c..bfca38f 100644
--- a/qtpylib/futures.py
+++ b/qtpylib/futures.py
@@ -140,13 +140,13 @@ def create_continuous_contract(df, resolution="1T"):
contract.drop(['expiry_y', 'expiry_x'], axis=1, inplace=True)
try:
- contract['open'] = contract['open'] + contract['gap']
- contract['high'] = contract['high'] + contract['gap']
- contract['low'] = contract['low'] + contract['gap']
- contract['close'] = contract['close'] + contract['gap']
+ contract['open'] += contract['gap']
+ contract['high'] += contract['gap']
+ contract['low'] += contract['gap']
+ contract['close'] += contract['gap']
# contract['volume'] = df['volume'].resample("D").sum()
except Exception as e:
- contract['last'] = contract['last'] + contract['gap']
+ contract['last'] += contract['gap']
contract.drop(['gap'], axis=1, inplace=True)
diff --git a/qtpylib/tools.py b/qtpylib/tools.py
index 67720ef..9fa9eb5 100644
--- a/qtpylib/tools.py
+++ b/qtpylib/tools.py
@@ -464,7 +464,7 @@ def get_timezone(as_timedelta=False):
offset_hour = -(datetime.datetime.now() -
datetime.datetime.utcnow()).seconds
- offset_hour = offset_hour // 3600
+ offset_hour //= 3600
offset_hour = offset_hour if offset_hour < 10 else offset_hour // 10
if as_timedelta: