Code Monkey home page Code Monkey logo

shoonyaapi-amibroker's Introduction

Shoonya API-AMI Broker

Instructions ( for 64-bit Amibroker):

  1. Copy the ShoonyaAPI_x64.dll to the Amibroker/Plugins folder
  2. Copy cpprest141_2_10.dll to the Amibroker folder
  3. Install Visual Studio redistributable from https://aka.ms/vs/17/release/vc_redist.x64.exe
  4. If you are running a 32-bit AMI Broker in a 64-bit operating system then you have to install Microsoft Visual Studio redistributable 32-bit.
  5. No Market Data Feeds You will be provided, You Need to Contact Another Data provider Vendor.

Instructions ( for 32-bit Amibroker):

  1. Copy the ShoonyaAPI.dll to the Amibroker/Plugins folder
  2. Copy cpprest141_2_10.dll to the Amibroker folder
  3. Install Visual Studio redistributable from https://aka.ms/vs/17/release/vc_redist.x86.exe
  4. If you are running a 32-bit AMI Broker in a 64-bit operating system then you have to install Microsoft Visual Studio redistributable 32-bit.
  5. No Market Data Feeds You will be provided, You Need to Contact Another Data provider Vendor.

First Login:

Enter the Login Credentials provided in the Credentials window. NorenAmicache.dat is created on successful login and restarting Amibroker will read credentials from the same.

User Video Guide of Integration:-

https://www.youtube.com/watch?v=TXApp6GUDSQ&t=248s

AFL strategy:

One of the most important aspects of AFL is that it is an array processing language. It operates on arrays (or rows/vectors) of data. As such you will need to build guards into your AFL so as not to signal for the same data repeatedly. Read More here.https://www.amibroker.com/guide/h_understandafl.html

ShoonyAPI.afl provides a basic framework for Entry and Exit Signals on the last candle. Setup the Parameters of the AFL below

stg      = ParamStr("Strategy Name","Systematic Trading");
flag     = ParamList("STATE","STOP|START");
lasttime = StrFormat("%0.f",LastValue(BarIndex()));
exch     = ParamList("Exchange","NSE|NFO|CDS |BSE |MCX");
tsym     = ParamStr("TradingSymbol","XYZ-EQ");    <=Note set this up correctly for each symbol, we do not pick up the symbol being plotted.
qty      = Param("Quantity",1,1,1000,1);
prd      = ParamList("Product", "I|C|M|B|H") "I" For MIS, "C" For CNC, "M" For NRML, "B" For BRACKET ORDER, "H" For COVER ORDER;

The following method collects the signals for each data record as per your AFL and evaluates the last record for an order signal. Example RSI_Crossover.afl

ShoonyaFireSignal(Buy,Sell,Short,Cover);


Place Order:

In your afl (or ShoonyaAPI.afl ) call the method when you want to send the signal to Shoonya

##NorenPlaceOrder(exch, tsym, qty, prc, trgprc, dscqty, prd, trantype, prctyp, ret, remarks);

DO NOT call this function directly in your AFL without a signal guard. This may result in multiple

Logs: AMIAPI_RequestLog.txt is created in the Amibroker directory. Check the same for confirmation.


Note: Amibroker runs the AFL code a couple of times every second for entire dataset. Make sure to build in checks to fire at the correct signal. An example of this is provided by ShoonyaAPI.afl


Example Buy Limit Order

exch = "NSE";
tsym = "CANBK-EQ";
qty = "1";
prc = "150";
trgprc = "0";
dscqty = "0";
prd     = "I";
trantype = "B";
prctyp = "LMT";
ret = "DAY";
remarks = "1234";

NorenPlaceOrder(exch, tsym, qty, prc, trgprc, dscqty, prd, trantype, prctyp, ret, remarks);       

Example Sell Limit Order


exch = "NSE";
tsym = "ACC-EQ";
qty = "1";
prc = "180";
trgprc = "0";
dscqty = "0";
prd     = "I";
trantype = "S";
prctyp = "LMT";
ret = "DAY";
remarks = "1234";
NorenPlaceOrder(exch, tsym, qty, prc, trgprc, dscqty, prd, trantype, prctyp, ret, remarks);  

Example Market Order


exch = "NSE";
tsym = "ACC-EQ";
qty = "1";
prc = "0";
trgprc = "0";
dscqty = "0";
prd     = "I";
trantype = "B";
prctyp = "MKT";
ret = "DAY";
remarks = "1234";
NorenPlaceOrder(exch, tsym, qty, prc, trgprc, dscqty, prd, trantype, prctyp, ret, remarks);       

Example StopLoss Limit Order

exch = "NSE";
tsym = "ACC-EQ";
qty = "1";
prc = Close;
trgprc = "100.5";
dscqty = "0";
prd     = "I";
trantype = "B";
prctyp = "SL-LMT";
ret = "DAY";
remarks = "1234";
NorenPlaceOrder(exch, tsym, qty, prc, trgprc, dscqty, prd, trantype, prctyp, ret, remarks);       

Example Cover Order

exch = "NSE";
tsym = "CANBK-EQ";
qty = "1";
prc = "155";
trgprc = "0";
dscqty = "0";
prd     = "I";
trantype = "B";
prctyp = "LMT";
ret = "DAY";
remarks = "1234";
blprc  = "150.5";

NorenPlaceCoverOrder(exch, tsym, qty, prc, trgprc, dscqty, prd, trantype, prctyp, ret, remarks, blprc);       

Example Bracket Order

exch = "NSE";
tsym = "CANBK-EQ";
qty = "1";
prc = "155";
trgprc = "0";
dscqty = "0";
prd     = "I";
trantype = "B";
prctyp = "LMT";
ret = "DAY";
remarks = "1234";
blprc  = "150.5";
bpprc  = "158";

NorenPlaceBracketOrder(exch, tsym, qty, prc, trgprc, dscqty, prd, trantype, prctyp, ret, remarks, blprc, bpprc);       

Symbol Master:- Check the Symbol Format from Below mention Symbol Master urls

NSE - Capital Market https://api.shoonya.com/NSE_symbols.txt.zip

NSE - Equity Derivatives https://api.shoonya.com/NFO_symbols.txt.zip

NSE - Currency Derivatives https://api.shoonya.com/CDS_symbols.txt.zip

MCX - Commodity https://api.shoonya.com/MCX_symbols.txt.zip

BSE - Capital Market https://api.shoonya.com/BSE_symbols.txt.zip

BSE - Equity Derivatives https://api.shoonya.com/BFO_symbols.txt.zip

Contact us

For any queries, feel free to reach us, by email at [email protected] or call 0172-4740000 & also Just visit our website there is a Live chat option.

shoonyaapi-amibroker's People

Contributors

kambalatech avatar shoonya-dev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

shoonyaapi-amibroker's Issues

Will the plugin interfere with another application that is logged into Shoonya API ? or vice versa

I have developed an application to feed market data to Amibroker from Shoonya API. I noticed that Amibroker asks TOTP code every time it is opened. My Datafeed application also has to provide TOTP code for loging into API. Question is - Will they close each others connection to API ?

Is the Shoonya Amibroker Plugin some secret source code that Finvasia does not want to part with it? Is it possible to share the source code on Github so that we can use it by making necessary changes?
If that is not possible, will you do changes to the plugin so that -

  1. Plugin status will be visible in Amibroker?
  2. After the plugin logs in to API, the generated susertoken should be written to some text file so that another application can use it.

Edit - After further testing, I found out that both applications log out each other. That is if I start Amibroker first, my app logs it out and if I start my app first, Amibroker logs in and my app gets disconnected from websocket

32 bit ShoonyaApi.dll does not work

Amibroker gives error message - The following plugins ShoonyApi.dll are 64 bit and as such cannot be loaded into 32 bit version of Amibroker you are running now

Plugin Status not visible in Amibroker.

I have downloaded 32bit plugin again and this time Amibroker did not complain. However, Plugin status does not appear in Amibroker. Therefore it is difficult to confirm whether it is connected or not.

32 bit plugin does not work

I am using 32-bit Amibroker and installed 32-bit Shoonya plugin. it does not work. Kindly re-examine what you uploaded here. Amibroker gives error message - The following plugins ShoonyApi.dll are 64 bit and as such cannot be loaded into 32 bit version of Amibroker you are running now.
Please do not give standard reply. I know programming

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.