Skip to content

Commit

Permalink
field name change in positions. added avatar_url
Browse files Browse the repository at this point in the history
  • Loading branch information
ajinasokan committed Jan 18, 2018
1 parent 9dc4b79 commit b7d945f
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 32 deletions.
7 changes: 3 additions & 4 deletions CHANGELOG.md
Expand Up @@ -17,7 +17,7 @@ New APIs added:

### Changes in Ticker

* Use Access Token to authenticate instead of Public Token
* Use Access Token to authenticate instead of Public Token. User id is not required.

```csharp
Ticker ticker = new Ticker(MyAPIKey, MyUserId, MyPublicToken);
Expand All @@ -26,7 +26,7 @@ Ticker ticker = new Ticker(MyAPIKey, MyUserId, MyPublicToken);
becomes,

```csharp
Ticker ticker = new Ticker(MyAPIKey, MyUserId, MyAccessToken);
Ticker ticker = new Ticker(MyAPIKey, MyAccessToken);
```

* Ticker now streams order updates
Expand All @@ -53,6 +53,7 @@ Ticker ticker = new Ticker(MyAPIKey, MyUserId, MyAccessToken);
| Verion 2 | Version 3 |
| :---: | :---: |
| _ | APIKey |
| _ | AvatarURL |
| PasswordReset | _ |
| MemberId | _ |
| OrderType | OrderTypes |
Expand Down Expand Up @@ -84,8 +85,6 @@ Ticker ticker = new Ticker(MyAPIKey, MyUserId, MyAccessToken);
| _ | DaySellPrice |
| NetBuyAmountM2M | _ |
| NetSellAmountM2M | _ |
| BuyM2M | BuyM2MValue |
| SellM2M | SellM2MValue |

<!-- **Added**
Expand Down
22 changes: 12 additions & 10 deletions KiteConnect/Structures.cs
@@ -1,8 +1,6 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace KiteConnect
{
Expand Down Expand Up @@ -279,14 +277,14 @@ public Position(Dictionary<string, dynamic> data)
OvernightQuantity = data["overnight_quantity"];
Exchange = data["exchange"];
SellValue = data["sell_value"];
BuyM2MValue = data["buy_m2m_value"];
BuyM2M = data["buy_m2m"];
LastPrice = data["last_price"];
TradingSymbol = data["tradingsymbol"];
Realised = data["realised"];
PNL = data["pnl"];
Multiplier = data["multiplier"];
SellQuantity = data["sell_quantity"];
SellM2MValue = data["sell_m2m_value"];
SellM2M = data["sell_m2m"];
BuyValue = data["buy_value"];
BuyQuantity = data["buy_quantity"];
AveragePrice = data["average_price"];
Expand All @@ -299,10 +297,10 @@ public Position(Dictionary<string, dynamic> data)
ClosePrice = data["close_price"];
Quantity = data["quantity"];
DayBuyQuantity = data["day_buy_quantity"];
// DayBuyValue = data["day_buy_value"];
DayBuyValue = data["day_buy_value"];
DayBuyPrice = data["day_buy_price"];
DaySellQuantity = data["day_sell_quantity"];
// DaySellValue = data["day_sell_value"];
DaySellValue = data["day_sell_value"];
DaySellPrice = data["day_sell_price"];
}
catch (Exception)
Expand All @@ -316,14 +314,14 @@ public Position(Dictionary<string, dynamic> data)
public int OvernightQuantity { get; }
public string Exchange { get; }
public decimal SellValue { get; }
public decimal BuyM2MValue { get; }
public decimal BuyM2M { get; }
public decimal LastPrice { get; }
public string TradingSymbol { get; }
public decimal Realised { get; }
public decimal PNL { get; }
public decimal Multiplier { get; }
public int SellQuantity { get; }
public decimal SellM2MValue { get; }
public decimal SellM2M { get; }
public decimal BuyValue { get; }
public int BuyQuantity { get; }
public decimal AveragePrice { get; }
Expand All @@ -337,10 +335,10 @@ public Position(Dictionary<string, dynamic> data)
public int Quantity { get; }
public int DayBuyQuantity { get; }
public decimal DayBuyPrice { get; }
//public decimal DayBuyValue { get; }
public decimal DayBuyValue { get; }
public int DaySellQuantity { get; }
public decimal DaySellPrice { get; }
//public decimal DaySellValue { get; }
public decimal DaySellValue { get; }
}

/// <summary>
Expand Down Expand Up @@ -560,6 +558,7 @@ public User(Dictionary<string, dynamic> data)
Products = (string[])data["data"]["products"].ToArray(typeof(string));
UserName = data["data"]["user_name"];
UserShortName = data["data"]["user_shortname"];
AvatarURL = data["data"]["avatar_url"];
Broker = data["data"]["broker"];
AccessToken = data["data"]["access_token"];
PublicToken = data["data"]["public_token"];
Expand All @@ -582,6 +581,7 @@ public User(Dictionary<string, dynamic> data)
public string[] Products { get; }
public string UserName { get; }
public string UserShortName { get; }
public string AvatarURL { get; }
public string Broker { get; }
public string AccessToken { get; }
public string PublicToken { get; }
Expand Down Expand Up @@ -626,6 +626,7 @@ public Profile(Dictionary<string, dynamic> data)
Products = (string[])data["data"]["products"].ToArray(typeof(string));
UserName = data["data"]["user_name"];
UserShortName = data["data"]["user_shortname"];
AvatarURL = data["data"]["avatar_url"];
Broker = data["data"]["broker"];
UserType = data["data"]["user_type"];
Exchanges = (string[])data["data"]["exchanges"].ToArray(typeof(string));
Expand All @@ -643,6 +644,7 @@ public Profile(Dictionary<string, dynamic> data)
public string[] Products { get; }
public string UserName { get; }
public string UserShortName { get; }
public string AvatarURL { get; }
public string Broker { get; }
public string UserType { get; }
public string[] Exchanges { get; }
Expand Down
6 changes: 2 additions & 4 deletions KiteConnect/Ticker.cs
Expand Up @@ -21,7 +21,6 @@ public class Ticker

// Configurations to create ticker connection
private string _apiKey;
private string _userID;
private string _accessToken;
private string _socketUrl = "";
private bool _isReconnect = false;
Expand Down Expand Up @@ -130,11 +129,10 @@ public class Ticker
/// <param name="Reconnect">Enables WebSocket autreconnect in case of network failure/disconnection.</param>
/// <param name="ReconnectInterval">Interval (in seconds) between auto reconnection attemptes. Defaults to 5 seconds.</param>
/// <param name="ReconnectTries">Maximum number reconnection attempts. Defaults to 50 attempts.</param>
public Ticker(string APIKey, string UserID, string AccessToken, string Root = null, bool Reconnect = false, int ReconnectInterval = 5, int ReconnectTries = 50, bool Debug = false)
public Ticker(string APIKey, string AccessToken, string Root = null, bool Reconnect = false, int ReconnectInterval = 5, int ReconnectTries = 50, bool Debug = false)
{
_debug = Debug;
_apiKey = APIKey;
_userID = UserID;
_accessToken = AccessToken;
_subscribedTokens = new Dictionary<UInt32, string>();
_interval = ReconnectInterval;
Expand All @@ -143,7 +141,7 @@ public Ticker(string APIKey, string UserID, string AccessToken, string Root = nu
if (!String.IsNullOrEmpty(Root))
_root = Root;
_isReconnect = Reconnect;
_socketUrl = _root + String.Format("?api_key={0}&user_id={1}&access_token={2}", _apiKey, _userID, _accessToken);
_socketUrl = _root + String.Format("?api_key={0}&access_token={1}", _apiKey, _accessToken);

// initialize websocket
_ws = new WebSocket(_socketUrl);
Expand Down
2 changes: 1 addition & 1 deletion KiteConnectSample/Program.cs
Expand Up @@ -338,7 +338,7 @@ private static void initSession()

private static void initTicker()
{
ticker = new Ticker(MyAPIKey, MyUserId, MyAccessToken);
ticker = new Ticker(MyAPIKey, MyAccessToken);

ticker.OnTick += OnTick;
ticker.OnReconnect += OnReconnect;
Expand Down
24 changes: 12 additions & 12 deletions KiteConnectTest/responses/positions.json
Expand Up @@ -21,11 +21,11 @@
"buy_quantity": 1,
"buy_price": 161.05,
"buy_value": 161050,
"buy_m2m_value": 161050,
"buy_m2m": 161050,
"sell_quantity": 0,
"sell_price": 0,
"sell_value": 0,
"sell_m2m_value": 0,
"sell_m2m": 0,
"day_buy_quantity": 1,
"day_buy_price": 161.05,
"day_buy_value": 161050,
Expand All @@ -52,11 +52,11 @@
"buy_quantity": 4,
"buy_price": 23139.75,
"buy_value": 92559,
"buy_m2m_value": 93084,
"buy_m2m": 93084,
"sell_quantity": 4,
"sell_price": 23340,
"sell_value": 93360,
"sell_m2m_value": 93360,
"sell_m2m": 93360,
"day_buy_quantity": 1,
"day_buy_price": 23388,
"day_buy_value": 23388,
Expand All @@ -83,11 +83,11 @@
"buy_quantity": 1,
"buy_price": 311,
"buy_value": 311,
"buy_m2m_value": 311,
"buy_m2m": 311,
"sell_quantity": 1,
"sell_price": 309,
"sell_value": 309,
"sell_m2m_value": 309,
"sell_m2m": 309,
"day_buy_quantity": 1,
"day_buy_price": 311,
"day_buy_value": 311,
Expand Down Expand Up @@ -116,11 +116,11 @@
"buy_quantity": 1,
"buy_price": 23388,
"buy_value": 23388,
"buy_m2m_value": 23388,
"buy_m2m": 23388,
"sell_quantity": 4,
"sell_price": 23340,
"sell_value": 93360,
"sell_m2m_value": 93360,
"sell_m2m": 93360,
"day_buy_quantity": 1,
"day_buy_price": 23388,
"day_buy_value": 23388,
Expand All @@ -147,11 +147,11 @@
"buy_quantity": 1,
"buy_price": 161.05,
"buy_value": 161050,
"buy_m2m_value": 161050,
"buy_m2m": 161050,
"sell_quantity": 0,
"sell_price": 0,
"sell_value": 0,
"sell_m2m_value": 0,
"sell_m2m": 0,
"day_buy_quantity": 1,
"day_buy_price": 161.05,
"day_buy_value": 161050,
Expand All @@ -178,11 +178,11 @@
"buy_quantity": 1,
"buy_price": 311,
"buy_value": 311,
"buy_m2m_value": 311,
"buy_m2m": 311,
"sell_quantity": 1,
"sell_price": 309,
"sell_value": 309,
"sell_m2m_value": 309,
"sell_m2m": 309,
"day_buy_quantity": 1,
"day_buy_price": 311,
"day_buy_value": 311,
Expand Down
1 change: 1 addition & 0 deletions KiteConnectTest/responses/profile.json
Expand Up @@ -5,6 +5,7 @@
"email": "xxxyyy@gmail.com",
"user_name": "AxAx Bxx",
"user_shortname": "abc",
"avatar_url": "http://zerodha.com",
"broker": "ZERODHA",
"exchanges": [
"BSE",
Expand Down
2 changes: 1 addition & 1 deletion README.md
@@ -1,4 +1,4 @@
# The Kite Connect API .Net client
# The Kite Connect API .Net client - Kite 3 Branch
The official .Net client for communicating with [Kite Connect API](https://kite.trade).

Kite Connect is a set of REST-like APIs that expose many capabilities required to build a complete investment and trading platform. Execute orders in real time, manage user portfolio, stream live market data (WebSockets), and more, with the simple HTTP API collection.
Expand Down

0 comments on commit b7d945f

Please sign in to comment.