Skip to content

Commit

Permalink
rounding all values to 2 digits
Browse files Browse the repository at this point in the history
  • Loading branch information
anilshanbhag committed Nov 10, 2019
1 parent 7bde2cd commit ef9f2e0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Config files
auth.data
instruments.data
watchlist.data

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down
16 changes: 8 additions & 8 deletions shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,10 @@ def do_l(self, arg):
previous_close = float(portfolio['adjusted_equity_previous_close'])
change = equity - previous_close
change_pct = '%.2f' % (change/previous_close * 100.0)

# format
change = f"{change:.3f}"
change = f"{change:.2f}"

# colorize
change_pct = color_data(change_pct)
change = color_data(change)
Expand Down Expand Up @@ -150,12 +150,13 @@ def do_l(self, arg):
price = market_data[i]['last_trade_price']
total_equity = float(price) * quantity
buy_price = float(position['average_buy_price'])
p_l = f"{total_equity - (buy_price * quantity):.3f}"

day_change = f"{float(market_data[i]['last_trade_price']) - float(market_data[i]['previous_close']):.3f}"
p_l = f"{total_equity - (buy_price * quantity):.2f}"
total_equity = f"{total_equity:.2f}"
buy_price = f"{buy_price:.2f}"
day_change = f"{float(market_data[i]['last_trade_price']) - float(market_data[i]['previous_close']):.2f}"
day_change_q_val = f"{float(quantity) * float(day_change):.2f}"
day_change_pct = f"{float(day_change) / float(market_data[i]['previous_close']) * 100:.2f}"
price = f"{float(price):.3f}"
price = f"{float(price):.2f}"

table_data.append([
symbol,
Expand Down Expand Up @@ -408,7 +409,6 @@ def do_c(self, arg):
return

try:
print(order_id)
self.trader.cancel_order(order_id)
print("Done")
except Exception as e:
Expand Down

0 comments on commit ef9f2e0

Please sign in to comment.