-
Notifications
You must be signed in to change notification settings - Fork 1
/
displayTrade.py
63 lines (50 loc) · 1.63 KB
/
displayTrade.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import streamlit as st
import datetime
from dummy import variable
import pandas as pd
st.set_page_config(
page_title="Predict stocks",
page_icon="🧊",
layout="wide",
initial_sidebar_state="expanded", )
# {str(datetime.date.today())}.txt
def colorChanger(val):
if isinstance(val, float):
color = 'red' if val < 0 else 'green'
return 'color: %s' % color
else:
pass
try:
st.title('Banknifty')
banknifty = open(f'/home/rajath/Automated-Trading/ubuntu/banknifty{str(datetime.date.today())}.txt')
linesbn = banknifty.read()
lst = []
for d in eval(linesbn):
lst.append(d)
df = pd.DataFrame.from_dict(lst).set_index('PurchaseTime')
# df.astype({
# 'boughtPrice': 'float64',
# 'ltpCE': 'float64',
# 'ltpPE': 'float64',
# 'PnL':'float64',
# 'PnlMul': 'float64',
# 'exitPrice': 'float64'
# })
styled = df.style.applymap(colorChanger)
st.dataframe(styled)
st.info(f"The total Profit is {df['PnLMul'].sum()} total number of trades till now are {len(df)}")
except Exception as e:
st.warning(e)
try:
st.title('Nifty')
nifty = open(f'/home/rajath/Automated-Trading/ubuntu/nifty{str(datetime.date.today())}.txt')
linesn = nifty.read()
lst = []
for d in eval(linesn):
lst.append(d)
df = pd.DataFrame.from_dict(lst).set_index('PurchaseTime')
styled = df.style.applymap(colorChanger)
st.dataframe(styled)
st.info(f"The total Profit is {df['PnLMul'].sum()} and total number of trades till now are {len(df)}")
except Exception as e:
st.warning(e)