This example is designed to help you understand how trading using the C# language works. This is a complete project that will:
- Grant you the authority to access the Tradovate Web Services using your Tradovate account credentials.
- Attempt to make trades on your behalf using the Tradovate REST API and Real-Time WebSocket service.
Tools you'll need:
- Mono.
- Your favorite IDE. VSCommunity is recommended if you're using a Mac (VSCommunity is unavailable for Linux).
wgetURL fetch service. Mac users follow this guide to acquirewget.- Java Runtime Environment.
Once you have your tools, clone this repository locally. Before you can run this example you must first generate and build the Tradovate.Services
project. This project is automatically created by the Swagger CLI tool when we run a code generation script provided with this repo. To generate
the code, follow these steps:
- Open a terminal and navigate to the directory into which you cloned this repository.
- run
sh codegen.sh. You should seewgetfetching the Swagger Codegen tools. Once this completes, you should see a lot of logging as the Swagger tool generates code. - Once this operation has succeeded, run
sh build-all.sh. This should compile and link the projects into an executable. - Navigate to the
binfolder created by the last operation. Run this command -mono Tradovate.Samples.exe <your-tradovate-username> <your-tradovate-pass>. Replace the angle-bracketed portions with your credentials, no brackets. - You should see the program log your Authentication, send a SyncRequest and begin attempting to trade! Congratulations, you've successfully built and run the Tradovate C# sample project.
Tools you'll need:
- VSCommunity IDE.
wgetURL fetch service, get it here.- Java Runtime Environment.
You also may need to add the
wgetand JRE tools to your system PATH. To do so, locate thewgetandjavaexecutables on your machine and add them to the system path using this command:
setx /M PATH "%PATH%;C:\path\to\wget;C:\path\to\java"
Once you have your tools, clone this repository locally. Before you can run this example you must first generate and build
the Tradovate.Servicesproject. This project is automatically created by the Swagger CLI tool when we run a code generation
script provided with this repo. To generate the code, follow these steps:
- Open a command line and navigate to the directory into which you cloned this repository.
- Run
codegen.mono.bat. If it is working properly, you should seewgetfetching the Swagger Codegen tool. Afterwards you should see a lot of logging while the code generation tool creates the Tradovate.Services project.
Once Tradovate.Services has been generated we need to compile it.
- Open VSCommunity and open the folder you cloned the repo into.
- On the right hand side, you should see the solution explorer. At the top bar select 'switch between solutions and available views'. Switch to the generated Tradovate.Services solution. Attempt to build this file. It may succeed, however some users may experience an issue linking dependencies. Should this happen, simply uninstall one of the dependencies using the NuGet manager, and then reinstall it*. This should update the VSCommunity metadata and link the dependencies correctly.
*NOTE: make sure to install the same package and version originally included with the generated code.
Now that we have the Tradovate.Services.dll file (which should be located in the /bin folder in Tradovate.Services) we should
simply be able to build the samples project. Right-click the Tradovate.Samples solution file and select Build.
Open a command line and navigate to the /bin/Debug/net5.0 folder in Tradovate.Samples and run the executable created by the previous steps:
Tradovate.Samples.exe <your-tradovate-username> <your-tradovate-pass>Replace the bracketet portions with your own Tradovate credentials (with no brackets). If this is successful, you should see the program log your Authentication, send a SyncRequest and begin attempting to trade! Congratulations, you've successfully built and run the Tradovate C# sample project.