Skip to content
This repository was archived by the owner on Nov 4, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 6 additions & 0 deletions .vs/VSWorkspaceState.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"ExpandedNodes": [
""
],
"PreviewInSolutionExplorer": false
}
Binary file added .vs/slnx.sqlite
Binary file not shown.
Binary file not shown.
Empty file.
Binary file added .vs/smartapi-dotnet/v17/.wsuo
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Empty file.
Binary file added AngelBroking/.vs/AngelBroking/v17/.suo
Binary file not shown.
Binary file added AngelBroking/.vs/AngelBroking/v17/.wsuo
Binary file not shown.
8 changes: 8 additions & 0 deletions AngelBroking/.vs/VSWorkspaceState.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"ExpandedNodes": [
"",
"\\AngelBroking"
],
"SelectedNode": "\\AngelBroking\\Constants.cs",
"PreviewInSolutionExplorer": false
}
Binary file added AngelBroking/.vs/slnx.sqlite
Binary file not shown.
10 changes: 8 additions & 2 deletions AngelBroking/AngelBroking.sln
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28307.1433
# Visual Studio Version 17
VisualStudioVersion = 17.5.33530.505
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AngelBroking", "AngelBroking\AngelBroking.csproj", "{D599945D-C73B-4D5A-BC71-3A209285B2B4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AngelBrokingConsoleApp", "..\..\..\smartapi-dotnet\smartapi-dotnet\Example\AngelBrokingConsoleApp\AngelBrokingConsoleApp\AngelBrokingConsoleApp.csproj", "{9408045F-FD8F-44BA-A149-B5534D2FE53E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -15,6 +17,10 @@ Global
{D599945D-C73B-4D5A-BC71-3A209285B2B4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D599945D-C73B-4D5A-BC71-3A209285B2B4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D599945D-C73B-4D5A-BC71-3A209285B2B4}.Release|Any CPU.Build.0 = Release|Any CPU
{9408045F-FD8F-44BA-A149-B5534D2FE53E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9408045F-FD8F-44BA-A149-B5534D2FE53E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9408045F-FD8F-44BA-A149-B5534D2FE53E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9408045F-FD8F-44BA-A149-B5534D2FE53E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
56 changes: 53 additions & 3 deletions AngelBroking/AngelBroking/AngelBroking.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>AngelBroking</RootNamespace>
<AssemblyName>AngelBroking</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -31,23 +32,65 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="AngelBroking, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\smartapi-dotnet\smartapi-dotnet\AngelBroking\AngelBroking\bin\Debug\AngelBroking.dll</HintPath>
</Reference>
<Reference Include="Base32">
<HintPath>..\..\..\..\smartapi-dotnet\smartapi-dotnet\AngelBroking\AngelBroking\bin\Debug\Base32.dll</HintPath>
</Reference>
<Reference Include="CsvTextFieldParser">
<HintPath>..\..\..\..\smartapi-dotnet\smartapi-dotnet\AngelBroking\AngelBroking\bin\Debug\CsvTextFieldParser.dll</HintPath>
</Reference>
<Reference Include="Microsoft.AspNetCore.WebUtilities">
<HintPath>..\..\..\..\smartapi-dotnet\smartapi-dotnet\AngelBroking\AngelBroking\bin\Debug\Microsoft.AspNetCore.WebUtilities.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.7.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Extensions.Primitives, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\smartapi-dotnet\smartapi-dotnet\AngelBroking\AngelBroking\bin\Debug\Microsoft.Extensions.Primitives.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Net.Http.Headers">
<HintPath>..\..\..\..\smartapi-dotnet\smartapi-dotnet\AngelBroking\AngelBroking\bin\Debug\Microsoft.Net.Http.Headers.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
</Reference>
<Reference Include="System.Core" />
<Reference Include="System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll</HintPath>
</Reference>
<Reference Include="System.Numerics" />
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
</Reference>
<Reference Include="System.Reactive, Version=5.0.0.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263, processorArchitecture=MSIL">
<HintPath>..\packages\System.Reactive.5.0.0\lib\netstandard2.0\System.Reactive.dll</HintPath>
</Reference>
<Reference Include="System.Reactive.Linq">
<HintPath>..\..\DLL\System.Reactive.Linq.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.5.3\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Text.Encodings.Web, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Text.Encodings.Web.7.0.0\lib\net462\System.Text.Encodings.Web.dll</HintPath>
</Reference>
<Reference Include="System.Text.Json, Version=7.0.0.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Text.Json.7.0.2\lib\net462\System.Text.Json.dll</HintPath>
</Reference>
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll</HintPath>
</Reference>
<Reference Include="System.Windows" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
Expand All @@ -68,11 +111,18 @@
<ItemGroup>
<Compile Include="AngelBrokingModel.cs" />
<Compile Include="Constants.cs" />
<Compile Include="ExceptionMessages.cs" />
<Compile Include="Exceptions.cs" />
<Compile Include="Helpers.cs" />
<Compile Include="IWebSocket.cs" />
<Compile Include="IWebSocket2.cs" />
<Compile Include="SmartApi.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Structures.cs" />
<Compile Include="Ticker.cs" />
<Compile Include="Utils.cs" />
<Compile Include="WebSocket.cs" />
<Compile Include="WebSocket2.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
Expand Down
46 changes: 28 additions & 18 deletions AngelBroking/AngelBroking/AngelBrokingModel.cs
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
using System;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;

namespace AngelBroking
{
class AngelBrokingModel
{
}
#region AngelBrokingModel
#region Websocketv1
/* Output Classes*/
public class AngelToken
{
public string jwtToken { get; set; }
public string refreshToken { get; set; }
public string feedToken { get; set; }
}
class AngelTokenResponse
public class AngelTokenResponse
{
public bool status { get; set; }
public string message { get; set; }
Expand Down Expand Up @@ -377,21 +379,6 @@ public class ConvertPositionRequest
public string transactiontype { get; set; }
public int quantity { get; set; }
public string type { get; set; }
//public string symboltoken { get; set; }
//public string producttype { get; set; }
//public string symbolname { get; set; }
//public string instrumenttype { get; set; }
//public string priceden { get; set; }
//public string pricenum { get; set; }
//public string genden { get; set; }
//public string gennum { get; set; }
//public string precision { get; set; }
//public string multiplier { get; set; }
//public string boardlotsize { get; set; }
//public string buyqty { get; set; }
//public string sellqty { get; set; }
//public string buyamount { get; set; }
//public string sellamount { get; set; }
}

public class CreateRuleRequest
Expand Down Expand Up @@ -437,4 +424,27 @@ public class LTPDataRequest
public string tradingsymbol { get; set; }
}
#endregion

#region WebSocketv2
public class TokenParams
{
public int mode { get; set; }
public List<TokenList> tokenList { get; set; }
}
public class TickerRequest
{
public string correlationID { get; set; }
public int action { get; set; }

[JsonPropertyName("params")]
public TokenParams param { get; set; }
}
public class TokenList
{
public int exchangeType { get; set; }
public List<string> tokens { get; set; }


}
#endregion
}
24 changes: 24 additions & 0 deletions AngelBroking/AngelBroking/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace AngelBroking
{
public class Constants
{
#region Websocketv1
// Products
public const string PRODUCT_TYPE_DELIVERY = "DELIVERY";
public const string PRODUCT_TYPE_MARGIN = "MARGIN";
Expand Down Expand Up @@ -51,5 +52,28 @@ public class Constants
public const string INTERVAL_THIRTY_MINUTE = "THIRTY_MINUTE";
public const string INTERVAL_ONE_HOUR = "ONE_HOUR";
public const string INTERVAL_ONE_DAY = "ONE_DAY";
#endregion

#region WebSocketv2
// Ticker modes
public const string MODE_FULL = "SnapQuote";
public const string MODE_QUOTE = "Quote";
public const string MODE_LTP = "LTP";

public const string PING = "ping";

public const int SNAPQUOTE = 3;
public const int QUOTE = 2;
public const int LTP = 1;

// WS URl
public const string ROOT = "ws://smartapisocket.angelone.in/smart-stream";

//Header parameters
public const string AUTHORIZATION = "Authorization";
public const string APIKEY = "x-api-key";
public const string CLIENTCODE = "x-client-code";
public const string FEEDTOKEN = "x-feed-token";
#endregion
}
}
39 changes: 39 additions & 0 deletions AngelBroking/AngelBroking/ExceptionMessages.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Linq;

namespace System
{
#region WebSocketv2
internal static partial class ExceptionExtensions
{
public static IEnumerable<string> Messages(this Exception ex)
{

if (ex == null) { yield break; }

yield return ex.Message;

IEnumerable<Exception> innerExceptions = Enumerable.Empty<Exception>();

if (ex is AggregateException && (ex as AggregateException).InnerExceptions.Any())
{
innerExceptions = (ex as AggregateException).InnerExceptions;
}
else if (ex.InnerException != null)
{
innerExceptions = new Exception[] { ex.InnerException };
}

foreach (var innerEx in innerExceptions)
{
foreach (string msg in innerEx.Messages())
{
yield return msg;
}
}
}

}
#endregion
}
53 changes: 53 additions & 0 deletions AngelBroking/AngelBroking/Exceptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net;

namespace AngelBroking
{
#region WebSocketv2
public class AngelException : Exception
{
HttpStatusCode Status;
public AngelException(string Message, HttpStatusCode HttpStatus, Exception innerException = null) : base(Message, innerException) { Status = HttpStatus; }
}

public class GeneralException : AngelException
{
public GeneralException(string Message, HttpStatusCode HttpStatus = HttpStatusCode.InternalServerError, Exception innerException = null) : base(Message, HttpStatus, innerException) { }
}

public class TokenException : AngelException
{
public TokenException(string Message, HttpStatusCode HttpStatus = HttpStatusCode.Forbidden, Exception innerException = null) : base(Message, HttpStatus, innerException) { }
}


public class PermissionException : AngelException
{
public PermissionException(string Message, HttpStatusCode HttpStatus = HttpStatusCode.Forbidden, Exception innerException = null) : base(Message, HttpStatus, innerException) { }
}

public class OrderException : AngelException
{
public OrderException(string Message, HttpStatusCode HttpStatus = HttpStatusCode.BadRequest, Exception innerException = null) : base(Message, HttpStatus, innerException) { }
}

public class InputException : AngelException
{
public InputException(string Message, HttpStatusCode HttpStatus = HttpStatusCode.BadRequest, Exception innerException = null) : base(Message, HttpStatus, innerException) { }
}

public class DataException : AngelException
{
public DataException(string Message, HttpStatusCode HttpStatus = HttpStatusCode.BadGateway, Exception innerException = null) : base(Message, HttpStatus, innerException) { }
}

public class NetworkException : AngelException
{
public NetworkException(string Message, HttpStatusCode HttpStatus = HttpStatusCode.ServiceUnavailable, Exception innerException = null) : base(Message, HttpStatus, innerException) { }
}
#endregion
}
2 changes: 2 additions & 0 deletions AngelBroking/AngelBroking/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

namespace AngelBroking
{
#region WebSocketv2
public static class Helpers
{
public static byte[] DecodeBase64Byte(this string value)
Expand Down Expand Up @@ -100,4 +101,5 @@ public class MessageEventArgs : EventArgs
{
public string Message { get; set; }
}
#endregion
}
7 changes: 6 additions & 1 deletion AngelBroking/AngelBroking/IWebSocket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AngelBroking
{
interface IWebSocket
public interface IWebSocket
{
#region WebSocketv1
bool IsConnected();
void ConnectforOrderQuote(string feedtype, string jwttoken, string clientcode, string apikey);
void ConnectforStockQuote(string feedtoken, string clientcode);
Expand All @@ -15,5 +17,8 @@ interface IWebSocket
void HeartBeat(string feedtoken, string clientcode);
void HeartBeat(string feedtype, string jwttoken, string clientcode, string apikey);
void RunScript(string feedtoken, string clientcode, string script, string task);

#endregion

}
}
Loading