Not sure where to post this.
I've put together something that approximately zero people have asked for. It's a PowerShell script that brute forces the layout of every set of trade buttons defined in your ToS workspace XML (mine has 38). I got tired of constantly fixing a bunch of stupid buttons every time I modified my ToS layout.
I've run this with ToS open -- no need to shut it down and restart. Just re-open the workspace layout and ToS will ingest your modifications from the XML file.
This is crappy code but I want it simple and easy to understand.
"If it's not simple; simply not"
Anyone else hacking their ToS XML file? I'm surprised nobody's talking about this -- I think there might be some low-hanging fruit in there when it comes to scriptable conveniences.
I've put together something that approximately zero people have asked for. It's a PowerShell script that brute forces the layout of every set of trade buttons defined in your ToS workspace XML (mine has 38). I got tired of constantly fixing a bunch of stupid buttons every time I modified my ToS layout.
I've run this with ToS open -- no need to shut it down and restart. Just re-open the workspace layout and ToS will ingest your modifications from the XML file.
Ruby:
# Your workspace XML file - MAKE A BACKUP COPY BEFORE YOU MESS WITH ANYTHING
# This process has had minimal testing.
$ToSXmlFile = "workspace.STONKS.xml"
# Your desired buttons in the order you want them to appear.
# These button names are not documented anywhere(?).
# Adding a new button to this list will require adding it manually within
# ToS, saving the workspace, then inspecting the XML file
# to learn the correct button names.
$NewButtons = '"FIRST_LINE;QUANTITY;BUY_BID;BUY_MKT;FLAT;MULTI_CANCEL;SELL_MKT;SELL_ASK;POSITION;WORKING_ORDERS;SECOND_LINE;TIF;ORDER_TEMPLATE;ORDER_SETUP"'
# PowerShell magic gnomes understand XML
$xml = New-Object XML
$xml.Load($ToSXmlFile)
# This uses XPath syntax to search the entire XML for TRADE_BUTTONS attributes.
# Every successful hit becomes an element added to the $OldButtons array.
$OldButtons = ($Xml.SelectNodes('//@TRADE_BUTTONS'))
# This steps through each element in the $OldButtons array overwriting whatever's
# in the Value property. New buttons go brrr.
$OldButtons | foreach { $_.Value = 'TRADE_BUTTONS='+$NewButtons }
# Write it out.
# FYI The Out-Xml cmdlet munches XML formatting - the Save() method does not.
$Xml.Save($ToSXmlFile)
This is crappy code but I want it simple and easy to understand.
"If it's not simple; simply not"
Anyone else hacking their ToS XML file? I'm surprised nobody's talking about this -- I think there might be some low-hanging fruit in there when it comes to scriptable conveniences.
Last edited: