Skip to content

Commit

Permalink
2.18 - Backtesting bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pranjal-joshi committed Nov 27, 2023
1 parent 645bf4c commit 8225117
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
5 changes: 4 additions & 1 deletion src/classes/Changelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from classes.ColorText import colorText

VERSION = "2.17"
VERSION = "2.18"

changelog = colorText.BOLD + '[ChangeLog]\n' + colorText.END + colorText.BLUE + '''
[1.00 - Beta]
Expand Down Expand Up @@ -277,4 +277,7 @@
[2.17]
1. Backtest Report column added for backtest screening runs
[2.18]
1. Critical backtest bug fixed (dropna axis-1 removed from results)
''' + colorText.END
7 changes: 5 additions & 2 deletions src/classes/Utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,13 +388,16 @@ def isBacktesting(backtestDate):
def calculateBacktestReport(data, backtestDict:dict):
try:
recent = data.head(1)['Close'].iloc[0]
for key, val in backtestDict.items():
for key, val in backtestDict.copy().items():
if val is not None:
try:
backtestDict[key] = str(round((backtestDict[key]-recent)/recent*100,1)) + "%"
except TypeError:
backtestDict[key] = None
del backtestDict[key]
# backtestDict[key] = None
continue
else:
del backtestDict[key]
except:
pass
return backtestDict
Expand Down
3 changes: 1 addition & 2 deletions src/screenipy.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ def main(testing=False, testBuild=False, downloadOnly=False, execute_inputs:list
"[+] Press any key to Exit!" + colorText.END)
sys.exit(0)

print(tickerOption)
if tickerOption == 'W' or tickerOption == 'N' or tickerOption == 'E' or tickerOption == 'S' or (tickerOption >= 0 and tickerOption < 16):
configManager.getConfig(ConfigManager.parser)
try:
Expand Down Expand Up @@ -478,8 +479,6 @@ def main(testing=False, testBuild=False, downloadOnly=False, execute_inputs:list
matchedSaveResults = pd.concat([matchedSaveResults, saveResults[saveResults['Stock'].str.contains(stk)]], ignore_index=True)
screenResults, saveResults = matchedScreenResults, matchedSaveResults

screenResults.dropna(axis=1, how='all', inplace=True)
saveResults.dropna(axis=1, how='all', inplace=True)
screenResults.sort_values(by=['Stock'], ascending=True, inplace=True)
saveResults.sort_values(by=['Stock'], ascending=True, inplace=True)
screenResults.set_index('Stock', inplace=True)
Expand Down
4 changes: 3 additions & 1 deletion src/streamlit_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ def dummy_call():

if Utility.tools.isBacktesting(backtestDate=backtestDate):
st.write(f'Running in :red[**Backtesting Mode**] for *T = {str(backtestDate)}* (Y-M-D) : [Backtesting data is subjected to availability as per the API limits]')
st.write('Backtesting is :red[Not Supported] for Intraday timeframes')
t = Thread(target=dummy_call)
t.start()

Expand Down Expand Up @@ -177,6 +178,7 @@ def get_extra_inputs(tickerOption, executeOption, c_index=None, c_criteria=None,
elif int(tickerOption) == 0 or tickerOption is None:
stock_codes:str = c_index.text_input('Enter Stock Code(s)', placeholder='SBIN, INFY, ITC')
execute_inputs = [tickerOption, executeOption, stock_codes.upper(), 'N']
return
elif int(executeOption) >= 0 and int(executeOption) < 4:
execute_inputs = [tickerOption, executeOption, 'N']
elif int(executeOption) == 4:
Expand Down Expand Up @@ -495,7 +497,7 @@ def get_extra_inputs(tickerOption, executeOption, c_index=None, c_criteria=None,
</style>
</head>
<body>
<marquee class="sampleMarquee" direction="left" scrollamount="7" behavior="scroll">Released in Development mode. This tool should be used only for analysis/study purposes. We do NOT provide any Buy/Sell advice for any Securities. Authors of this tool will not be held liable for any losses. Understand the Risks subjected with Markets before Investing.</marquee>
<marquee class="sampleMarquee" direction="left" scrollamount="7" behavior="scroll">This tool should be used only for Analysis/Study purposes. We do NOT provide any Buy/Sell advice for any Securities. Authors of this tool will not be held liable for any losses. Understand the Risks subjected with Markets before Investing.</marquee>
</body>
</html>
'''
Expand Down

0 comments on commit 8225117

Please sign in to comment.