initial commit

This commit is contained in:
Roland W-H 2025-01-28 15:25:41 +00:00
commit cafe2da484
13 changed files with 597 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/designer.exe - Shortcut.lnk

10
.idea/SIPPCompare.iml generated Normal file
View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.venv" />
</content>
<orderEntry type="jdk" jdkName="Python 3.13 (SIPPCompare)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View File

@ -0,0 +1,7 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="PROJECT_PROFILE" value="Default" />
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>

8
.idea/modules.xml generated Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/SIPPCompare.iml" filepath="$PROJECT_DIR$/.idea/SIPPCompare.iml" />
</modules>
</component>
</project>

6
.idea/vcs.xml generated Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

118
.idea/workspace.xml generated Normal file
View File

@ -0,0 +1,118 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AutoImportSettings">
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="1c319b92-4392-4dac-a78b-6bf35361fa44" name="Changes" comment="">
<change afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/SIPPCompare.iml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/inspectionProfiles/profiles_settings.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/modules.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/vcs.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/gui/main_gui.ui" afterDir="false" />
<change afterPath="$PROJECT_DIR$/gui/output_window.ui" afterDir="false" />
<change afterPath="$PROJECT_DIR$/gui/platform_edit.ui" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main_window.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/output_window.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/platform_edit.py" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="Python Script" />
</list>
</option>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="ProjectColorInfo">{
&quot;associatedIndex&quot;: 4
}</component>
<component name="ProjectId" id="2sAQ1fm73VpffDk7OE0m4M4RpDt" />
<component name="ProjectLevelVcsManager" settingsEditedManually="true" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"Python.Run main.executor": "Run",
"Python.main.executor": "Run",
"Python.main_window.executor": "Run",
"RunOnceActivity.ShowReadmeOnStart": "true",
"RunOnceActivity.git.unshallow": "true",
"git-widget-placeholder": "master",
"ignore.virus.scanning.warn.message": "true",
"last_opened_file_path": "C:/dev/SIPPCompare/main.py",
"settings.editor.selected.configurable": "editor.preferences.fonts.default"
}
}]]></component>
<component name="RecentsManager">
<key name="MoveFile.RECENT_KEYS">
<recent name="C:\dev\SIPPCompare\src" />
</key>
</component>
<component name="RunManager">
<configuration name="Run main" type="PythonConfigurationType" factoryName="Python">
<module name="SIPPCompare" />
<option name="ENV_FILES" value="" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="SDK_NAME" value="Python 3.13 (SIPPCompare)" />
<option name="WORKING_DIRECTORY" value="" />
<option name="IS_MODULE_SDK" value="false" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<option name="SCRIPT_NAME" value="C:\dev\SIPPCompare\src\main.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
<option name="REDIRECT_INPUT" value="false" />
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
</component>
<component name="SharedIndexes">
<attachedChunks>
<set>
<option value="bundled-python-sdk-495700d161d3-aa17d162503b-com.jetbrains.pycharm.community.sharedIndexes.bundled-PC-243.22562.220" />
</set>
</attachedChunks>
</component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="1c319b92-4392-4dac-a78b-6bf35361fa44" name="Changes" comment="" />
<created>1737895685673</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1737895685673</updated>
</task>
<servers />
</component>
<component name="Vcs.Log.Tabs.Properties">
<option name="TAB_STATES">
<map>
<entry key="MAIN">
<value>
<State />
</value>
</entry>
</map>
</option>
</component>
</project>

174
gui/main_gui.ui Normal file
View File

@ -0,0 +1,174 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>420</width>
<height>250</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>420</width>
<height>250</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>420</width>
<height>250</height>
</size>
</property>
<property name="windowTitle">
<string>SIPPCompare</string>
</property>
<property name="tabShape">
<enum>QTabWidget::TabShape::Rounded</enum>
</property>
<widget class="QWidget" name="centralwidget">
<widget class="QWidget" name="formLayoutWidget">
<property name="geometry">
<rect>
<x>10</x>
<y>0</y>
<width>401</width>
<height>191</height>
</rect>
</property>
<layout class="QFormLayout" name="formLayout">
<property name="leftMargin">
<number>5</number>
</property>
<property name="topMargin">
<number>5</number>
</property>
<property name="rightMargin">
<number>5</number>
</property>
<property name="bottomMargin">
<number>5</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="value_lab">
<property name="text">
<string>Pension value</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="value_input">
<property name="inputMask">
<string>£0000000000</string>
</property>
<property name="text">
<string>£</string>
</property>
<property name="maxLength">
<number>11</number>
</property>
<property name="frame">
<bool>true</bool>
</property>
<property name="cursorPosition">
<number>1</number>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QLabel" name="mix_lab">
<property name="text">
<string>Investment mix (funds 50% / shares 50%)</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignCenter</set>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QSlider" name="mix_slider">
<property name="maximum">
<number>100</number>
</property>
<property name="value">
<number>50</number>
</property>
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="tickPosition">
<enum>QSlider::TickPosition::NoTicks</enum>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="share_trades_lab">
<property name="text">
<string>Annual share trades</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="share_trades_combo">
<property name="editable">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="fund_trades_lab">
<property name="text">
<string>Annual fund trades</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QComboBox" name="fund_trades_combo">
<property name="editable">
<bool>true</bool>
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<widget class="QPushButton" name="calc_but">
<property name="text">
<string>Calculate</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
<widget class="QStatusBar" name="statusbar">
<property name="enabled">
<bool>true</bool>
</property>
</widget>
<widget class="QMenuBar" name="menuBar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>420</width>
<height>33</height>
</rect>
</property>
<widget class="QMenu" name="menuPlatforms">
<property name="title">
<string>File</string>
</property>
<addaction name="actionEdit_Platforms"/>
</widget>
<addaction name="menuPlatforms"/>
</widget>
<action name="actionEdit_Platforms">
<property name="text">
<string>Edit Platforms</string>
</property>
</action>
</widget>
<resources/>
<connections/>
</ui>

71
gui/output_window.ui Normal file
View File

@ -0,0 +1,71 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ResultsWindow</class>
<widget class="QWidget" name="ResultsWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>400</width>
<height>300</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>400</width>
<height>300</height>
</size>
</property>
<property name="windowTitle">
<string>Results</string>
</property>
<widget class="QTextEdit" name="output">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>380</width>
<height>250</height>
</rect>
</property>
</widget>
<widget class="QPushButton" name="res_ok_but">
<property name="geometry">
<rect>
<x>320</x>
<y>270</y>
<width>75</width>
<height>24</height>
</rect>
</property>
<property name="text">
<string>OK</string>
</property>
</widget>
</widget>
<resources/>
<connections>
<connection>
<sender>res_ok_but</sender>
<signal>clicked(bool)</signal>
<receiver>ResultsWindow</receiver>
<slot>close()</slot>
<hints>
<hint type="sourcelabel">
<x>357</x>
<y>281</y>
</hint>
<hint type="destinationlabel">
<x>199</x>
<y>149</y>
</hint>
</hints>
</connection>
</connections>
</ui>

70
gui/platform_edit.ui Normal file
View File

@ -0,0 +1,70 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PlatformEdit</class>
<widget class="QWidget" name="PlatformEdit">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>771</width>
<height>502</height>
</rect>
</property>
<property name="windowTitle">
<string>Platform Editor</string>
</property>
<widget class="QScrollArea" name="scrollArea">
<property name="geometry">
<rect>
<x>180</x>
<y>130</y>
<width>331</width>
<height>191</height>
</rect>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>329</width>
<height>189</height>
</rect>
</property>
<widget class="QListWidget" name="listWidget">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>311</width>
<height>141</height>
</rect>
</property>
<item>
<property name="text">
<string>up to</string>
</property>
</item>
</widget>
<widget class="QPushButton" name="pushButton">
<property name="geometry">
<rect>
<x>210</x>
<y>160</y>
<width>111</width>
<height>24</height>
</rect>
</property>
<property name="text">
<string>PushButton</string>
</property>
</widget>
</widget>
</widget>
</widget>
<resources/>
<connections/>
</ui>

9
src/main.py Normal file
View File

@ -0,0 +1,9 @@
import sys
from PyQt6.QtWidgets import QApplication
import main_window
app = QApplication(sys.argv)
window = main_window.SIPPCompare()
window.show()
app.exec()

88
src/main_window.py Normal file
View File

@ -0,0 +1,88 @@
from PyQt6.QtWidgets import QMainWindow
from PyQt6 import uic
import platform_edit
import output_window
class SIPPCompare(QMainWindow):
def __init__(self):
super().__init__()
uic.loadUi("gui/main_gui.ui", self)
# Define class variables
self.tiered_fees = [
[0, 250000, 1000000, 2000000],
[0, 0.25, 0.1, 0.05]
]
self.fund_deal_fee = 1.5
self.share_plat_fee = 0.0025
self.share_plat_max_fee = 3.5
self.share_deal_fee = 5
self.share_deal_reduce_trades = 10
self.share_deal_reduce_amount = 3.5
self.result = None
self.platform_win = None
self.output_win = None
# Handle events
self.calc_but.clicked.connect(self.calculate_fee)
self.actionEdit_Platforms.triggered.connect(self.show_platform_edit)
self.mix_slider.valueChanged.connect(self.update_slider_lab)
# Display slider position as mix between two nums (funds/shares)
def update_slider_lab(self):
slider_val = self.mix_slider.value()
self.mix_lab.setText(f"Investment mix (funds {slider_val}% / shares {100 - slider_val}%)")
#mix_percent_lab_str = f"{slider_val}% / {100 - slider_val}%"
#self.mix_percent_lab.setText(mix_percent_lab_str)
# Calculate fees
def calculate_fee(self):
value_num = float(self.value_input.text()[1:])
slider_val = self.mix_slider.value()
funds_value = (slider_val / 100) * value_num
fund_trades_num = int(self.fund_trades_combo.currentText())
fund_deal_fees = fund_trades_num * self.fund_deal_fee
fund_plat_fees = 0
remaining = funds_value
for i in range(1, len(self.tiered_fees[0])):
band = self.tiered_fees[0][i]
prev_band = self.tiered_fees[0][i - 1]
fee = self.tiered_fees[1][i]
gap = (band - prev_band)
if remaining > gap:
fund_plat_fees += gap * (fee / 100)
remaining -= gap
else:
fund_plat_fees += remaining * (fee / 100)
break
shares_value = (1 - (slider_val / 100)) * value_num
share_plat_fees = self.share_plat_fee * shares_value
if (share_plat_fees / 12) > self.share_plat_max_fee:
share_plat_fees = self.share_plat_max_fee * 12
share_trades_num = int(self.share_trades_combo.currentText())
share_deal_fees = self.share_deal_fee * share_trades_num
if (share_trades_num / 12) > self.share_deal_reduce_trades:
share_deal_fees = self.share_deal_reduce_amount * share_trades_num
self.show_output_win(fund_plat_fees, fund_deal_fees, share_plat_fees, share_deal_fees)
# Show the output window - this func is called from calculate_fee()
def show_output_win(self, fund_plat_fees, fund_deal_fees, share_plat_fees, share_deal_fees):
# Check window isn't already open
if self.output_win is None:
self.output_win = output_window.OutputWindow()
# Refresh the results when new fees are calculated
self.output_win.display_output(fund_plat_fees, fund_deal_fees, share_plat_fees, share_deal_fees)
self.output_win.show()
# Show the platform editor window (currently useless)
def show_platform_edit(self):
# Check window isn't already open
if self.platform_win is None:
self.platform_win = platform_edit.PlatformEdit()
self.platform_win.show()

28
src/output_window.py Normal file
View File

@ -0,0 +1,28 @@
from PyQt6.QtWidgets import QWidget
from PyQt6 import uic
class OutputWindow(QWidget):
def __init__(self):
super().__init__()
uic.loadUi("gui/output_window.ui", self)
def display_output(self, fund_plat_fees: float, fund_deal_fees: float,
share_plat_fees: float, share_deal_fees: float):
results_str = "Fees breakdown:"
results_str += "\n\nPlatform fees:"
results_str += f"\n\tFund platform fees: £{round(fund_plat_fees, 2):.2f}"
results_str += f"\n\tShare platform fees: £{round(share_plat_fees, 2):.2f}"
total_plat_fees = fund_plat_fees + share_plat_fees
results_str += f"\n\tTotal platform fees: £{round(total_plat_fees, 2):.2f}"
results_str += "\n\nDealing fees:"
results_str += f"\n\tFund dealing fees: £{round(fund_deal_fees, 2):.2f}"
results_str += f"\n\tShare dealing fees: £{round(share_deal_fees, 2):.2f}"
total_deal_fees = fund_deal_fees + share_deal_fees
results_str += f"\n\tTotal dealing fees: £{round(total_deal_fees, 2):.2f}"
total_fees = total_plat_fees + total_deal_fees
results_str += f"\n\nTotal fees: £{round(total_fees, 2):.2f}"
self.output.setText(results_str)

7
src/platform_edit.py Normal file
View File

@ -0,0 +1,7 @@
from PyQt6.QtWidgets import QWidget
from PyQt6 import uic
class PlatformEdit(QWidget):
def __init__(self):
super().__init__()
uic.loadUi("gui/platform_edit.ui", self)