TrueData-DotNet
1.3.2
dotnet add package TrueData-DotNet --version 1.3.2
NuGet\Install-Package TrueData-DotNet -Version 1.3.2
<PackageReference Include="TrueData-DotNet" Version="1.3.2" />
paket add TrueData-DotNet --version 1.3.2
#r "nuget: TrueData-DotNet, 1.3.2"
// Install TrueData-DotNet as a Cake Addin
#addin nuget:?package=TrueData-DotNet&version=1.3.2
// Install TrueData-DotNet as a Cake Tool
#tool nuget:?package=TrueData-DotNet&version=1.3.2
###Introduction:
This nugget Package attempts to make it easy for you to connect to TrueData Market Data Apis, thereby allowing you to concentrate on startegy development, while this library works to get you all the data you need from the TrueData backend both for Real Time & Historical.
Please make sure you follow us on our Telegram channel where we push a lot of information with regards to API updates, implementation ideas, tips & tricks to use this library & raw feed, etc...
We have also built a sandbox environmemt for testing the raw feed. Please feel free to use this environment to check/test/compare your results with the raw data feed (real time & historical).
We are trying to improve this nugget Package continuously and feedback for the same is welcome.
It is essential to ensure that the data received through our APIs is not being utilized for any commercial purposes. Additionally, please be mindful that all information or data provided to you is exclusively intended for your internal use and must be utilized and discontinued at your end as required.
WebSocket APIs
- Live data (Streaming Ticks) - Enabled by Default
- Live Data (Streaming 1 min bars)
- Live Data (Streaming 5 min bars)
- Live data (Streaming Ticks + 1 min bars)
- Live Data (Streaming Ticks + 5 min bars)
- Live Data (Streaming Ticks + 1 min bars + 5 min bars)
- Live Data (Streaming 1 min + 5 min bars)
- Option Greek
Note:- Kindly note that data that is not enabled by default may require exchange approvals, which vary depending on the specific exchange and segment in question. For any inquiries or clarifications, please feel free to reach out to our dedicated support team.
REST APIs
- Bar/OHLC Data
- Ticks Data (ticks)
- Gainers / Losers
- Bhavcopy
Analytics and Greeks - ADDON
- Top Gainers / Losers
- Industry Gainer / Losers
- Options Greeks
Getting Started
Install the Package from nuget.org and it will be installed automatically
Minimum Requirements The minimum required Framework versions are:- .netstandard 2.0
In-built dependencies All dependencies should get installed automatically when you install the TrueData DotNet nuget Package.
Logging In To WebSocket API By Just Creation of Object you can use the events and functions of package which will allow you to login
TDWebSocket tDWebSocket; Truedata WebSocket
tDWebSocket = new TDWebSocket("your_id", "your_pwd", "websocket_url", port_no); //Login to Truedata WebSocket service
TDMaster tDMaster; Truedata Master
tDMaster = new TDMaster("your_id", "your_pwd"); //To download latest master
//Websocket Important Event Callbacks
tDWebSocket.OnConnect += TDWebSocket_OnConnect;
tDWebSocket.OnDataArrive += TDWebSocket_OnDataArrive;
tDWebSocket.OnClose += TDWebSocket_OnClose;
tDWebSocket.OnError += TDWebSocket_OnError;
tDWebSocket.ConnectAsync(); Connect to WebSocket
Replace Your_Id & Your_Password strings with your actual Id & Password along with port.
WebSocket API allows us to receive real time data feed based subscription like tick,1 min, 5 min so on. WebSocket Responses and Subscription
WebSocket will send the real time data according to subscription of your Symbols:
//To start WebSocket streaming one need to subscribe symbols or tokens as follows:
string[] symbols = { "NIFTY-I", "RELIANCE", "NIFTY 50", "CRUDEOIL-I", "USDINR-I", "SENSEX", "RELIANCE_BSE" };
tDWebSocket.Subscribe(symbols);
Whenever the trade happens or bid-ask changes, event will be called Timestamp of Symbol,LTP,Volume,Open ,High , Low , Close and OI for symbols which are mentioned in subscribe symbol list, complete on data arrive handling code is given below:
private static void TDWebSocket_OnDataArrive(object sender, EventDataArgs e)
{
if (e.JsonMsg.Contains("bidask"))
{
BidAsk b = new BidAsk();
b = JsonConvert.DeserializeObject<BidAsk>(e.JsonMsg);
Console.WriteLine(b.SymbolId + "-" + b.Timestamp + "-" + b.Bid + "-" + b.Ask + "-" + b.BidQty);
}
else if (e.JsonMsg.Contains("trade"))
{
SnapData t = new SnapData();
t = JsonConvert.DeserializeObject<SnapData>(e.JsonMsg);
Scrip s = scrips.Where(v => v.symbolid == t.SymbolId).FirstOrDefault();
if (s != null)
Console.WriteLine(s.symbol + "-" + t.SymbolId + "-" + t.Timestamp + "-" + t.LTP + "-" + t.Volume + "-" + t.Open + "-" + t.High + "-" + t.Low + "-" + t.PrevClose);
}
else if (e.JsonMsg.Contains("HeartBeat"))
{
HeartBeat hb = new HeartBeat();
hb = JsonConvert.DeserializeObject<HeartBeat>(e.JsonMsg);
Console.WriteLine("Heartbeat " + hb.timestamp + "-" + hb.message);
}
else if (e.JsonMsg.Contains("TrueData"))
{
Console.WriteLine("Connected");
string[] symbols = { "NIFTY-I", "RELIANCE", "NIFTY 50", "CRUDEOIL-I", "USDINR-I", "SENSEX", "RELIANCE_BSE" };
tDWebSocket.Subscribe(symbols);
}
}
Above we can see the response from API for symbol in format of " trade" and 1 minute bar along with HeartBeat.
Logging In to History To login to history use TDHistory REST API's object:
TDHistory tDHistory;
tDHistory = new TDHistory("your_id", "your_pwd");
tDHistory.login();
Replace Your_Id & Your_Password strings with your actual Id & Password. It has so many features that you can use. Like GetLastNBars, GetLastNTicks so these functions do return you the essential info.
TrueData REST API Endpoints
After Logging into History API you can use certain functions for easing your experience for trading info.
GetBars - OHLC This has Symbol , Number of Bar , Boolean for Json/csv response , time interval as parameter above call will return you 1 bar of HDFC which is of 15 min.
string csvResponse = tDHistory.GetBarHistory("ACC", DateTime.Today.AddHours(-1), DateTime.Now,false, Constants.Interval_1Min, false);
Console.WriteLine("History 1min for ACC");
Console.WriteLine(csvResponse);
GetTicks
string csvTickData = tDHistory.GetTickHistory("ACC", false, DateTime.Now.AddHours(-0.5), DateTime.Now,false, true);
Console.WriteLine("History Tick for ACC");
Console.WriteLine(csvTickData);
GetLastNBar
string csvLastNBar = tDHistory.GetLastNBars("HDFC", 1, false, "15min");
Console.WriteLine("Last 10 bar of HDFC");
Console.WriteLine(csvLastNBar);
GetLastNTicks
string csvLastNBar = tDHistory.GetLastNTicks("HDFC", true, 1);
Console.WriteLine("Last 10 bar of HDFC");
Console.WriteLine(csvLastNBar);
GetBhavCopyStatus
Console.WriteLine(tDHistory.GetBhavCopyStatus("BSEFO", true));
GetBhavCopy
string csvBhavCopy = tDHistory.GetBhavCopy("EQ", DateTime.Today, true);
Console.WriteLine("Today's Bhavcopy");
Console.WriteLine(csvBhavCopy);
GetBhavCopy
string csvGainers = tDHistory.GetTopGainers("NSEEQ", true, 10);
Console.WriteLine("Today's Gainers");
Console.WriteLine(csvGainers);
GetTopGainers
string csvLosers = tDHistory.GetTopLosers("NSEEQ", true, 10);
Console.WriteLine("Today's Losers");
Console.WriteLine(csvLosers);
Console.ReadLine();
GetCorporateActions
string csvCorpAction = tDHistory.GetCorporateActions("AARTIIND", true);
Console.WriteLine("Corporate Actions");
Console.WriteLine(csvCorpAction);
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- K4os.Compression.LZ4 (>= 1.2.15)
- Newtonsoft.Json (>= 13.0.1)
- System.Runtime.CompilerServices.Unsafe (>= 5.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated | |
---|---|---|---|
1.3.2 | 113 | 3/12/2024 | |
1.3.1 | 117 | 3/7/2024 | |
1.3.0 | 142 | 12/11/2023 | |
1.2.9 | 113 | 12/6/2023 | |
1.2.8 | 111 | 11/22/2023 | |
1.2.7 | 82 | 11/20/2023 | |
1.2.6 | 96 | 11/19/2023 | |
1.2.5 | 83 | 11/16/2023 | |
1.2.4 | 83 | 11/14/2023 | |
1.2.3 | 81 | 11/12/2023 | |
1.2.2 | 79 | 11/9/2023 | |
1.2.1 | 112 | 10/4/2023 | |
1.2.0 | 132 | 9/25/2023 | |
1.1.9 | 1,219 | 8/21/2022 | |
1.1.8 | 314 | 12/24/2021 | |
1.1.7 | 263 | 12/23/2021 | |
1.1.6 | 280 | 12/11/2021 | |
1.1.5 | 327 | 10/26/2021 | |
1.1.4 | 347 | 10/26/2021 | |
1.1.2 | 372 | 10/25/2021 | |
1.1.1 | 414 | 7/29/2021 | |
1.1.0 | 340 | 7/20/2021 | |
1.0.5 | 338 | 7/19/2021 | |
1.0.4 | 323 | 7/16/2021 | |
1.0.3 | 338 | 7/15/2021 | |
1.0.2 | 346 | 7/15/2021 | |
1.0.1 | 411 | 5/21/2021 | |
1.0.0 | 496 | 5/21/2021 |