I've been developing my own app to execute my own algorithm. Since i was familiar with VBA prior to this, i prototyped a lot of tests and proof-of-concept in VBA. Then came time to pick a platform, and a language, to build the app that actually executes through the various exchanges i want to work with.
So I've looked into Visual Studio Code, and Visual Studio 2022, settling on Visual Studio 2022 free version. On that platform I've looked into C# and of course Visual Basic. C# offers the most open-source libraries for trading, so that is the logical direction to go. For example, there is a lot of open-source websockets code available through either GitHub and/or NuGet, an easily accessible library facility through Visual Studio.
So the logical step would have been to skip Visual Basic, and begin to transfer coding skills over to C#. Along with this, the logical next step would be to employ a "console" app, the easiest/fastest way to get an app up and running. So i began to consume some excellent C# courses available on YouTube.
But then i realized that i would probably not be in need of websockets for a while, since my algorithm would not be able to overcome trading fees for the short time frames, without extensive use of limit orders and a ton of code that i would need to make that work.
Instead, i thought i might just use market orders on longer time frames, and the REST API that are available from pretty much any exchange/broker. At the same time, i realized that VBA, in Excel, can be transformed into a console app.
Did you know, for example, that you can type in the name of any Sub routine into the "Immediate" window, and have it executed? Yes, and you can even include parameters (arguments) in those calls. Of course, then you can output anything you want to see into the same Immediate window. That, basically, is a console app.
So, since i had already, painstakingly, found and adapted some REST API code for VBA, i decided to just keep going with VBA for a while longer before making the big switch up to C# on Visual Studio. My big problem was that it is very difficult to find and adapt any websocket code for VBA. That is what almost pushed me to switch platforms. But now that my demands are not so heavy, i feel i can turn Excel into a fully automated console app.
With REST API, about all you can demand, is data updates about every one minute. You can certainly explore the shortest limits, but that is what i decided is all i need for the longer time frames that i would be using, combined with market orders. A market order means you can register your order on your exchanges server, ready to go, if price ever crosses your threshold. This way, you don't need to be watching price every split second through websockets like you would if you were using limit orders.
The key to an app like this is the Application.OnTime function, which will call the entry point of your program on any time schedule you want, down to every second. Of course, i am calling the entry point of my app every minute. In between calls, the program is totally not running, as if it was totally finished. This means there are no variables in memory, which is completely wiped out. This means that to maintain state, you have to write to file, and read from file, every minute that the application gets called.
The other key to a console app is to have lists of menus (commands) that you make available for yourself, whatever it is you want to control from a command line. So that starts with usage lists that help remind you how to use your own functions, which get harder and harder to remember, the bigger and more complex your program becomes.
Here is an example of three of my main usage lists:
So I've looked into Visual Studio Code, and Visual Studio 2022, settling on Visual Studio 2022 free version. On that platform I've looked into C# and of course Visual Basic. C# offers the most open-source libraries for trading, so that is the logical direction to go. For example, there is a lot of open-source websockets code available through either GitHub and/or NuGet, an easily accessible library facility through Visual Studio.
So the logical step would have been to skip Visual Basic, and begin to transfer coding skills over to C#. Along with this, the logical next step would be to employ a "console" app, the easiest/fastest way to get an app up and running. So i began to consume some excellent C# courses available on YouTube.
But then i realized that i would probably not be in need of websockets for a while, since my algorithm would not be able to overcome trading fees for the short time frames, without extensive use of limit orders and a ton of code that i would need to make that work.
Instead, i thought i might just use market orders on longer time frames, and the REST API that are available from pretty much any exchange/broker. At the same time, i realized that VBA, in Excel, can be transformed into a console app.
Did you know, for example, that you can type in the name of any Sub routine into the "Immediate" window, and have it executed? Yes, and you can even include parameters (arguments) in those calls. Of course, then you can output anything you want to see into the same Immediate window. That, basically, is a console app.
So, since i had already, painstakingly, found and adapted some REST API code for VBA, i decided to just keep going with VBA for a while longer before making the big switch up to C# on Visual Studio. My big problem was that it is very difficult to find and adapt any websocket code for VBA. That is what almost pushed me to switch platforms. But now that my demands are not so heavy, i feel i can turn Excel into a fully automated console app.
With REST API, about all you can demand, is data updates about every one minute. You can certainly explore the shortest limits, but that is what i decided is all i need for the longer time frames that i would be using, combined with market orders. A market order means you can register your order on your exchanges server, ready to go, if price ever crosses your threshold. This way, you don't need to be watching price every split second through websockets like you would if you were using limit orders.
The key to an app like this is the Application.OnTime function, which will call the entry point of your program on any time schedule you want, down to every second. Of course, i am calling the entry point of my app every minute. In between calls, the program is totally not running, as if it was totally finished. This means there are no variables in memory, which is completely wiped out. This means that to maintain state, you have to write to file, and read from file, every minute that the application gets called.
The other key to a console app is to have lists of menus (commands) that you make available for yourself, whatever it is you want to control from a command line. So that starts with usage lists that help remind you how to use your own functions, which get harder and harder to remember, the bigger and more complex your program becomes.
Here is an example of three of my main usage lists: