C# Library

Place and manage orders from your own .NET code, on any supported broker, with one set of functions.

Runs on .NETDirect connectionAbout 5 minutesBroker independent
In short

The C# library lets you automate trading from your own .NET code. Install it from NuGet, create one AutoTrader instance with your API key, then call functions like place order, modify order, or read positions. The same code works on any supported broker.

What it is

The C# library is a broker independent trading client for Indian stock exchanges. You write your strategy once in .NET and run it against any broker that AutoTrader Web supports. The same function calls work everywhere, so changing broker does not mean rewriting your code.

It is a good fit if you build in C#, want full control over your logic, or run your strategy on a server.

How it connects

C# is a direct client. Your code calls AutoTrader Web over a secure web connection, and AutoTrader Web passes each instruction on to your broker. Nothing extra needs to run on your computer.

How your orders reach your brokerNothing else to install
DirectExcel · AmiBroker · MetaTrader · Python · Java · C# · HTTP REST
Your code or tool
on your PC or a server
secure web
AutoTrader Web
the platform
Your broker
any supported broker

Your code talks to the platform over the web. There is nothing to install on your machine beyond the library itself.

Before you begin

Have these ready first:

  • A .NET project where you can add a NuGet package.
  • An AutoTrader Web account. Your strategy runs through it.
  • An API key. Generate it in your account settings, then keep it private.
  • At least one broker account added, so your orders have somewhere to go.

Install

The library is published on NuGet, so you can add it to any C# project.

From the command line, in your project folder:

# Install, or upgrade to the newest release
dotnet add package StocksDeveloper.AutoTraderWeb.Api

The current version is 1.4.0. The command above gives you the newest release, so you do not need to write a version number. If your project already has an older one, the AutoTrader bracket and cover order calls need 1.4.0 or newer.

Initialize

Create one AutoTrader instance and share it across your application. Pass your API key, which you can find in your account settings.

IAutoTrader autoTrader = AutoTrader.CreateInstance(
    "<your-api-key>",
    AutoTrader.SERVER_URL);

A minimal working example

This reads the live positions for one account, then prints them. The same instance handles placing, modifying and cancelling orders too.

using com.dakshata.autotrader.api;
using com.dakshata.trading.model.platform;

IAutoTrader autoTrader = AutoTrader.CreateInstance(
    "<your-api-key>",
    AutoTrader.SERVER_URL);

// Read live positions for a pseudo account
IOperationResponse<ISet<PlatformPosition>> response =
    autoTrader.ReadPlatformPositions("ABC123");

Console.WriteLine("Message: {0}", response.Message);
foreach (PlatformPosition p in response.Result)
    Console.WriteLine("{0}", p);

To place an order instead, call PlaceRegularOrder with your account, "<exchange>", a symbol such as "SBIN", the trade type, order type and product type. Each function is documented with examples in the API reference. Common ones: place a regular order, modify an order, cancel an order, read positions, and square off a position.

Write the code with AI

You can have an AI coding assistant (ChatGPT, Claude, Gemini or Copilot) write your C# code for you. Many programmers now start this way, and it is much faster than a blank page. It only works well if the AI reads our documentation first. Without it, the AI guesses function names that look right and then fail.

  1. Give it our C# file first: stocksdeveloper.in/ai/trading-api/csharp.txt. It has every API call with C# examples, and nothing from other languages to mix up. If your tool cannot open links, open the file yourself, save it, and attach it to the chat.
  2. Then send a prompt like this one. Replace the parts in CAPITALS.
Read this file first: https://stocksdeveloper.in/ai/trading-api/csharp.txt
It is the official reference for the AutoTrader Web C# (.NET) library.
Use only the functions, parameters and values it defines.

Write a C# program that DESCRIBE WHAT YOU WANT IT TO DO HERE.
My account nickname is MY_ACCOUNT. Read the API key from an
environment variable, never from the code.

Then check your code line by line against the reference, and list
anything you were not sure about instead of guessing it.
  1. Test it before real money. Run it once with the smallest quantity, in one account only.

Never paste your API key into an AI chat. Ask the AI to read it from an environment variable instead, as the prompt above does. Anyone who has your key can place orders in your accounts.

Build with AI has more prompts, the mistakes these tools make, and what to check before you trade with the result.

Next steps

Was this page helpful?

Last updated 8 October 2026