Dissecting the Nest Plus Auto Trading API

Hello,

I tried contacting Omnesys via their email and phone numbers mentioned on website, but no response from them.
Had anyone purchased subscription of NEST API recently ?

Thanks
 

pkgmtnl

Well-Known Member
Thanks for your valuable notes, Yusi.

In an attempt to make it fully automated, i edited and added some codes. I know it is a half-baked one, let it be a starter.

1. Paste Your own afl with Buy and Sell conditions.
2.The buy and sell condition variables named here are buy11 and sell11 resp.

Code:
//Author : Ranjicgnr
Title = " ";
 
_SECTION_BEGIN("MaualTradingInt1V00 ");
 
X2 = Param("Button X Offset", 0, 0, 2000, 100);
Y2 = Param("Button Y Offset", 0, 0, 2000, 100);
X1 = Param("Button Size", 100, 100, 300, 50);
 
EnableRealTimeControl = ParamList("Enable Controls", "No|Yes", 0);
EnableAutoTrade = ParamList("Enable Autotrade", "No|Yes", 0);
BuyPriceSelection = ParamList("Buy Price", "Bid Price|Ask Price|LTP", 0);
SellPriceSelection = ParamList("Sell Price", "Ask Price|Bid Price|LTP", 0);
ProductType = ParamList("Product Type", "MIS|NRML", 0);
OrderType = ParamList("Order Type", "LIMIT|MARKET", 0);
ClientIdValue = ParamStr("Client Id", "CLIENTID");
LotQuantity = Param("Lot Quantity", 1000, 50, 100000, 10);  // Default Trade Qty.
 
//firstflag=0;
if(StaticVarGetText("firstflag")=="")
{
    StaticVarSet("OrderNo", 0);
     
    StaticVarSet("LTPSave", 0);
    StaticVarSet("LTQSave", 0);
    StaticVarSet("VolumeTemp", 0);
    StaticVarSet("AskSave", 0);
    StaticVarSet("BidSave", 0);
     
    StaticVarSet("LastLTPColor", colorGrey40);
    StaticVarSet("LastLTQColor", colorGrey40);
    StaticVarSet("LastAskColor", colorGrey40);
    StaticVarSet("LastBidColor", colorGrey40);
     
    StaticVarSetText ("firstflag","0");
}
 
if(StaticVarGetText("firstflag"+Name())=="")
{
    StaticVarSet(("Buy_Price" + Name()), 0);
    StaticVarSet(("Buy_Qty" + Name()), 0);
    StaticVarSet(("Sell_Price" + Name()), 0);
    StaticVarSet(("Sell_Qty" + Name()), 0);
    StaticVarSet(("AvgBuy_Price" + Name()), 0);
    StaticVarSet(("NetBuy_Qty" + Name()), 0);
    StaticVarSet(("AvgSell_Price" + Name()), 0);
    StaticVarSet(("NetSell_Qty" + Name()), 0);
     
    StaticVarSetText("firstflag"+Name(), "0");
}
 
 
 
if(EnableAutoTrade == "Yes" && EnableRealTimeControl == "Yes")
{
    if(StaticVarGetText("firstflagforNest")=="")
    {
        nestplus = Null;
        if(IsNull(nestplus))
        {
            nestplus = CreateStaticObject("Nest.PlusApi");
            nestplus.SetObjectName("RKRAutoTrade");
        }
        StaticVarSetText ("firstflagforNest","0");
    }
     
}
 
TempBuyPrice = StaticVarGet(("Buy_Price" + Name()));
TempSellPrice = StaticVarGet(("Sell_Price" + Name()));
TempBuyQty = StaticVarGet(("Buy_Qty" + Name()));
TempSellQty = StaticVarGet(("Sell_Qty" + Name()));
 
LTPTemp = StaticVarGet("LTPSave");
LTQTemp = StaticVarGet("LTQSave");
VolumeTemp = StaticVarGet("VolumeTemp");
AskTemp = StaticVarGet("AskSave");
BidTemp = StaticVarGet("BidSave");
 
LTPLastTemp = LastValue(C);
VolumeLastTemp = LastValue(Volume);
 
LTQLastTemp = (VolumeLastTemp - VolumeTemp);
 
if(LTQLastTemp < 0)
{
    LTQLastTemp = LTQLastTemp * -1;
}
 
if(LTQLastTemp == 0)
{
    LTQLastTemp = LTQTemp;
}
 
 
AskLastTemp = LastValue(Aux1);
BidLastTemp = LastValue(Aux2);
 
LTPColor = StaticVarGet("LastLTPColor");
LTQColor = StaticVarGet("LastLTQColor");
AskColor = StaticVarGet("LastAskColor");
BidColor = StaticVarGet("LastBidColor");
 
 
if(LTPTemp > LTPLastTemp)
{
    LTPColor = colorRed;
}
else if(LTPTemp < LTPLastTemp)
{
    LTPColor = colorGreen;
}
 
if(LTQTemp > LTQLastTemp)
{
    LTQColor = colorRed;
}
else if(LTQTemp < LTQLastTemp)
{
    LTQColor = colorGreen;
}
 
if(AskTemp > AskLastTemp)
{
    AskColor = colorRed;
}
else if(AskTemp < AskLastTemp)
{
    AskColor = colorGreen;
}
 
if(BidTemp > BidLastTemp)
{
    BidColor = colorRed;
}
else if(BidTemp < BidLastTemp)
{
    BidColor = colorGreen;
}
 
StaticVarSet("LastLTPColor", LTPColor);
StaticVarSet("LastLTQColor", LTQColor);
StaticVarSet("LastAskColor", AskColor);
StaticVarSet("LastBidColor", BidColor);
 
StaticVarSet("LTPSave", LTPLastTemp);
StaticVarSet("LTQSave", LTQLastTemp);
StaticVarSet("VolumeTemp", VolumeLastTemp);
StaticVarSet("AskSave", AskLastTemp);
StaticVarSet("BidSave", BidLastTemp);
 
X0 = 20;
Y0 = 10;
 
procedure DrawData (Text, x1, y1, x2, y2, colorFrom, colorTo)
{
    GfxSetOverlayMode(0);
    GfxSelectFont("Verdana", 8.5, 700);
    GfxSetBkMode(1);
    GfxGradientRect(x1, y1, x2, y2, colorFrom, colorTo);
    GfxDrawText(Text, x1, y1, x2, y2, 32|1|4|16);
}
GfxSetTextColor(colorWhite);
 
 
 
NetBuyQtyDisplay = StaticVarGet(("NetBuy_Qty" + Name()));
if(NetBuyQtyDisplay == 0)
{
    BuyAvgPriceDisplay = 0;
}
else
{
    BuyAvgPriceDisplay = (StaticVarGet(("AvgBuy_Price" + Name())))/(NetBuyQtyDisplay/LotQuantity);
}
 
NetSellQtyDisplay = StaticVarGet(("NetSell_Qty" + Name()));
if(NetSellQtyDisplay == 0)
{
    SellAvgPriceDisplay = 0;
}
else
{
    SellAvgPriceDisplay = (StaticVarGet(("AvgSell_Price" + Name())))/(NetSellQtyDisplay/LotQuantity);
}
 
 
 
TempNetQuantity = NetBuyQtyDisplay - NetSellQtyDisplay;
TempNetValue = (SellAvgPriceDisplay * NetSellQtyDisplay) - (BuyAvgPriceDisplay * NetBuyQtyDisplay);
 
TempNetQuantityColor = colorGrey40;
TempNetValueColor = colorGrey40;
 
if(TempNetQuantity > 0)
{
    TempNetQuantityColor = colorGreen;
}
else if(TempNetQuantity < 0)
{
    TempNetQuantityColor = colorRed;
}
 
if(TempNetValue > 0)
{
    TempNetValueColor = colorGreen;
}
else if(TempNetValue < 0)
{
    TempNetValueColor = colorRed;
}
 
DrawData (Name(), X0, Y0, X0+300, Y0+20, colorGrey40, colorGrey40);
DrawData (Date(), X0+305, Y0, X0+470, Y0+20, colorGrey40, colorGrey40);
DrawData ("Open : " + Open, X0+475, Y0, X0+625, Y0+20, colorGrey40, colorGrey40);
DrawData ("Close : " + Close, X0+630, Y0, X0+780, Y0+20, colorGrey40, colorGrey40);
DrawData ("High : " + High, X0+785, Y0, X0+935, Y0+20, colorGrey40, colorGrey40);
DrawData ("Low : " + Low, X0+940, Y0, X0+1090, Y0+20, colorGrey40, colorGrey40);
DrawData ("Volume : " + NumToStr(Volume,1,0), X0+1095, Y0, X0+1300, Y0+20, colorGrey40, colorGrey40);
DrawData ("% Change : " + NumToStr( (((C-O)*100)/O), 1.2, True), X0+1305, Y0, X0+1450, Y0+20, colorGrey40, colorGrey40);
 
if(EnableRealTimeControl == "Yes")
{
    DrawData ("Buy Price : " + TempBuyPrice, X0, Y0+25, X0+150, Y0+45, colorGrey40, colorGrey40);
    DrawData ("Buy Qty : " + TempBuyQty, X0+155 , Y0+25, X0+305, Y0+45, colorGrey40, colorGrey40);
    DrawData ("Sell Price : " + TempSellPrice, X0+310, Y0+25, X0+460, Y0+45, colorGrey40, colorGrey40);
    DrawData ("Sell Qty : " + TempSellQty, X0+465, Y0+25, X0+615, Y0+45, colorGrey40, colorGrey40);
 
    DrawData ("BuyAvgPrice : " + BuyAvgPriceDisplay, X0+620, Y0+25, X0+770, Y0+45, colorGrey40, colorGrey40);
    DrawData ("NetBuyQty : " + NetBuyQtyDisplay, X0+775 , Y0+25, X0+925, Y0+45, colorGrey40, colorGrey40);
    DrawData ("SellAvgPrice : " + SellAvgPriceDisplay, X0+930, Y0+25, X0+1080, Y0+45, colorGrey40, colorGrey40);
    DrawData ("NetSellQty : " + NetSellQtyDisplay, X0+1085, Y0+25, X0+1235, Y0+45, colorGrey40, colorGrey40);
     
    TempNestOredrNo = ClientIdValue + NumToStr(Now(3),1,0) + "00" + StaticVarGet("OrderNo");
     
    DrawData ("NetQty : " + TempNetQuantity, X0+520, Y0+50, X0+670, Y0+70, TempNetQuantityColor, TempNetQuantityColor);
    DrawData ("NetValue : " + TempNetValue, X0+675, Y0+50, X0+900, Y0+70, TempNetValueColor, TempNetValueColor);
    DrawData ("Order No : " + TempNestOredrNo, X0+905, Y0+50, X0+1150, Y0+70, colorGrey40, colorGrey40);
     
    DrawData ("LTP : " + LTPLastTemp, X0, Y0+50, X0+125, Y0+70, LTPColor, LTPColor);
    DrawData ("LTQ : " + NumToStr(LTQLastTemp,1,0), X0+130, Y0+50, X0+255, Y0+70, LTQColor, LTQColor);
    DrawData ("Bid : " + BidLastTemp, X0+260, Y0+50, X0+385, Y0+70, AskColor, AskColor);
    DrawData ("Ask : " + AskLastTemp, X0+390, Y0+50, X0+515, Y0+70, BidColor, BidColor);
}
 
X0 = X2 + 20;
Y0 = Y2 + 100;
 
 
//LBClick = GetCursorMouseButtons() == 9; // Click
LBClickB =IIf(ExRem(Buy11,Sell11),1,0);
MouseX  = Nz(GetCursorXPosition(1));        // 
MouseY  = Nz(GetCursorYPosition(1));        //
 
procedure DrawBut (Text, x1, y1, x2, y2, colorFrom, colorTo)
{
    GfxSetOverlayMode(0);
    GfxSelectFont("Verdana", 9, 700);
    GfxSetBkMode(1);
    GfxGradientRect(x1, y1, x2, y2, colorFrom, colorTo);
    GfxDrawText(Text, x1, y1, x2, y2, 32|1|4|16);
}
GfxSetTextColor(colorWhite);
 
if(EnableRealTimeControl == "Yes")
{
 
    DrawBut ("Buy", X0, Y0, X0+X1, Y0+30, colorGreen, colorGreen);
    CursorInBuyButton = MouseX >= X0 AND MouseX <= X0+X1 AND MouseY >= Y0 AND MouseY <= Y0+30;
    BuyButtonClick = CursorInBuyButton AND LBClickB;
    if (BuyButtonClick=1) 
    { 
        DrawBut("Buy", X0+X1+10, Y0, X0+X1+75, Y0+30,  colorGrey40, colorGrey40);
        TempBuy = LastValue(DateTime());
        StaticVarSet(("BuyIndex" + Name()),  TempBuy);
         
        TempBuyLastQty = StaticVarGet(("NetBuy_Qty" + Name()));
        TempNetBuyQty = (TempBuyLastQty + LotQuantity);
         
        TempBuyLastPrice = StaticVarGet(("AvgBuy_Price" + Name()));
         
        if(BuyPriceSelection == "Bid Price")
        {
            BuyPriceValue = BidLastTemp;
        }
        else if(BuyPriceSelection == "Ask Price")
        {
            BuyPriceValue = AskLastTemp;
        }
        else
        {
            BuyPriceValue = LTPLastTemp;
        }
         
        if(TempBuyLastQty == 0)
        {
            TempAvgBuyPrice = BuyPriceValue;
        }
        else
        {
            TempAvgBuyPrice = (BuyPriceValue + TempBuyLastPrice);
        }
         
        StaticVarSet(("Buy_Price" + Name()),  BuyPriceValue);
        StaticVarSet(("Buy_Qty" + Name()),  LotQuantity);
         
        StaticVarSet(("AvgBuy_Price" + Name()),  TempAvgBuyPrice);
        StaticVarSet(("NetBuy_Qty" + Name()),  TempNetBuyQty);
         
        if(EnableAutoTrade == "Yes" && EnableRealTimeControl == "Yes")
        {
            LastOrderNo = StaticVarGet("OrderNo");
            LastOrderNo++;
            StaticVarSet("OrderNo", LastOrderNo);
            TempOrderNo = ClientIdValue + NumToStr(Now(3),1,0) + "00" + LastOrderNo;
            TempName = Name() + "-EQ";
            nestplus.PlaceOrder("BUY", TempOrderNo, "NSE", TempName, "DAY", OrderType, LotQuantity, BuyPriceValue, 0.0, 0, ProductType, ClientIdValue);
        }   
    }
 	 LBClickS=IIf(ExRem(Sell11,Buy11),1,0);
    DrawBut ("Sell", X0, Y0+40, X0+X1, Y0+70, colorRed, colorRed);
    CursorInSellButton = MouseX >= X0 AND MouseX <= X0+X1 AND MouseY >= Y0+40 AND MouseY <= Y0+70;
    SellButtonClick = CursorInSellButton AND LBClickS;
    if (SellButtonClick=1) 
    { 
        DrawBut("Sell", X0+X1+10, Y0, X0+X1+75, Y0+30,  colorGrey40, colorGrey40);
        TempSell = LastValue(DateTime());
        StaticVarSet(("SellIndex" + Name()),  TempSell);
         
        TempSellLastQty = StaticVarGet(("NetSell_Qty" + Name()));
        TempNetSellQty = (TempSellLastQty + LotQuantity);
         
        TempSellLastPrice = StaticVarGet(("AvgSell_Price" + Name()));
         
        if(SellPriceSelection == "Ask Price")
        {
            SellPriceValue = AskLastTemp;
        }
        else if(SellPriceSelection == "Bid Price")
        {
            SellPriceValue = BidLastTemp;
        }
        else
        {
            SellPriceValue = LTPLastTemp;
        }
         
        if(TempSellLastQty == 0)
        {
            TempAvgSellPrice = SellPriceValue;
        }
        else
        {
            TempAvgSellPrice = (SellPriceValue + TempSellLastPrice);
        }
         
        StaticVarSet(("Sell_Price" + Name()),  SellPriceValue); 
        StaticVarSet(("Sell_Qty" + Name()),  LotQuantity);
         
        StaticVarSet(("AvgSell_Price" + Name()),  TempAvgSellPrice);    
        StaticVarSet(("NetSell_Qty" + Name()),  TempNetSellQty);
         
        if(EnableAutoTrade == "Yes" && EnableRealTimeControl == "Yes")
        {
            LastOrderNo = StaticVarGet("OrderNo");
            LastOrderNo++;
            StaticVarSet("OrderNo", LastOrderNo);
            TempOrderNo = ClientIdValue + NumToStr(Now(3),1,0) + "00" + LastOrderNo;
            TempName = Name() + "-EQ";
            nestplus.PlaceOrder("SELL", TempOrderNo, "NSE", TempName, "DAY", OrderType, LotQuantity, SellPriceValue, 0.0, 0, ProductType, ClientIdValue);
        }   
    }
 
    DrawBut ("Clear Data", X0, Y0+80, X0+X1, Y0+110, colorGrey40, colorGrey40);
    CursorInClearButton = MouseX >= X0 AND MouseX <= X0+X1 AND MouseY >= Y0+80 AND MouseY <= Y0+110;
    ClearButtonClick = CursorInClearButton AND LBClick;
    if (ClearButtonClick) 
    { 
        DrawBut("Clear", X0+X1+10, Y0, X0+X1+75, Y0+30,  colorGrey40, colorGrey40);
        StaticVarRemove(("BuyIndex" + Name()));
        StaticVarRemove(("SellIndex" + Name()));
        StaticVarSetText("firstflag"+Name(), "");
    }
 
    BuyTempData = StaticVarGet(("BuyIndex" + Name()));
    SellTempData = StaticVarGet(("SellIndex" + Name()));
 
    //Buy = IIf(DateTime() == BuyTempData, 1, 0);
    //Sell = IIf(DateTime() == SellTempData, 1, 0);
 
    Buyshape = Buy * shapeUpArrow;
    SellShape = Sell * shapeDownArrow;
    PlotShapes( Buyshape, colorBrightGreen, 0, Low );
    PlotShapes( SellShape, colorRed, 0, High );
    GraphXSpace = 5;
}
 
_SECTION_END();
 
_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
//_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} \nOpen : %g, Close : %g (%.1f%%) \nLow : %g, High : %g (%.1f%%) \nVolume : " +WriteVal( V, 1.0 ) +" {{VALUES}}", O, C,(((C-O)*100)/O), L, H, (((H-L)*100)/L) ));
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
Hello Aroon ji,
Just got NEST Api activated from Broker.
Does it Punch and execute Orders Automatically?
Can u put strategy of http: // www. marketcalls.in/amibroker/supertrend-v3-0-afl-code-buy-sell-alerts. html into it and reproduce here.
 
Hi... I am a retail trader presently. I want to get the API to fetch Live data and make my strategy in Excel-Macros (VBA.NET) and then based on its triggers i want to place orders to Nest {Semi automated system}…. (Dont want to involve Amibroker…. will do by custom made software in VB.net)

For this purpose , i need the guidance that how should i proceed.

I might have missed on the information, but after going thru the forum, there are certain queries as under which i think will help solve the doubts of many to be algo traders like me ....

1.Does Nest plus API- retail version (300 types cost p/m ) allow to get the Live data in Excel or i need to go for higher version of API- dealer version(1000 types cost p/m)….{{i want it to be semi automated only to start with … needing my manual confirmation to finally place order}}

2. IF retail version get me live data to build my strategies , then its fine for me …… ELSE i will go for Dealer version of API, the queries for that are:-
a. Cost ? (Is it still 12000 per month as recurring cost for custom software , besides fixed expenses)
b. Exam ? ( NISM Series VIII Certification )
c. CA audit ? (is Self appointed CA okay… and he will see the order log and based on that he see the risk evaluation or we need to disclose strategy…. how is it done, pl clarify)
d. Exchange approval ? ( It is UAT based and exchange will also just see the order log and decide or we need to disclose strategy…. how is it done, pl clarify)
e. time taken in whole process
f. Any other requirement from individual’s side
g. Lastly, in the Dealer version , do we need to do full automation from DAY 1 or we have the option of semi-automated system initially till we test it properly.
 

yusi

Well-Known Member
Hi... I am a retail trader presently. I want to get the API to fetch Live data and make my strategy in Excel-Macros (VBA.NET) and then based on its triggers i want to place orders to Nest {Semi automated system}…. (Dont want to involve Amibroker…. will do by custom made software in VB.net)

For this purpose , i need the guidance that how should i proceed.

I might have missed on the information, but after going thru the forum, there are certain queries as under which i think will help solve the doubts of many to be algo traders like me ....

1.Does Nest plus API- retail version (300 types cost p/m ) allow to get the Live data in Excel or i need to go for higher version of API- dealer version(1000 types cost p/m)….{{i want it to be semi automated only to start with … needing my manual confirmation to finally place order}}

...
The Nest Plus API, retail or dealer, provides just six functions as given earlier in this thread. The difference between the two is that the former requires manual confirmation of order placement and can handle 1 client. The API does not provide any data. Since you are unclear on this, ignoring point 2 entirely.

As a first focus, assume that you use the retail version of the Nest Plus API to trigger/manage orders from Excel. Some have attempted to trigger orders in Nest Trader without using the Nest Plus API at all; but that is a later consideration.

Your second need is getting the data in Excel and by this I assume that you need the latest top-line data. In another thread, Vijkris has indicated you to use the inbuilt RTD based Link to Excel feature.

Unless your needs are more or different, using Link to Excel should be the second focus. In terms of cost and ease, nothing comes anywhere close. I hear that NeoTrade, maybe others, offers an Excel API for their datafeed; but that is a later consideration.

This should be enough to get your other parts off the ground.

There may be other options, and vendors, for automating trades rather than building from the ground up -- these are mentioned elsewhere -- but that is not your question.
 
Hi ,

I want to code my strategy in Amibroker ... can Amibroker programmer help ... preferable from pune. can contact me on 9 8 5 0 8 0 0 3 0 9

Sriheri
 

cloudTrader

Well-Known Member
@ Yusi,

I have never used the real time auto scanning feature of Amibroker . Is the Real Time Auto scan [Auto Repeat in every 5 minutes] possible along with the data fetching utility ?

Thanks.
 

yusi

Well-Known Member
Is the Real Time Auto scan [Auto Repeat in every 5 minutes] possible along with the data fetching utility ?
Help me out here -- under what scenarios do you imagine that the autoscan may not work, given any data feed? Have seen this question asked earlier, but never got a grip on the premise behind it.

The periodic Auto scan and data feed are orthogonal, and one should not interfere with the other.
 

Similar threads