API  Version 2.0.1
Low-Latency HFT API
 All Classes Functions Variables
API2::SGContext Class Referenceabstract

The SGContext class The main class to be inherited for creating a new Strategy. More...

#include <sgContext.h>

Public Member Functions

virtual ~SGContext ()
 ~SGContext A destructor
 
 SGContext (StrategyParameters *params, const std::string sgName)
 SGContext Constructor. More...
 
COMMON::InstrumentcreateNewInstrument (UNSIGNED_LONG symbolId, bool regMktData, bool useSnapShot=false, bool useOhlc=true)
 createNewInstrument To add a new Instrument in the strategy
The Pointer to the added Instrument is set in instrument passed as reference More...
 
COMMON::InstrumentcreateNewInstrument (const std::string &instrumentName, bool regMktData=false, bool useSnapShot=true, bool useOhlc=false)
 createNewInstrument To add a new Instrument in the strategy
The Pointer to the added Instrument is set in instrument passed as reference More...
 
SingleOrdercreateNewOrder (COMMON::Instrument *instrument, const UNSIGNED_LONG &qty=0, const UNSIGNED_LONG &discQty=0, const DATA_TYPES::OrderMode &mode=CONSTANTS::CMD_OrderMode_BUY, const DATA_TYPES::OrderType &type=CONSTANTS::CMD_OrderType_LIMIT, const DATA_TYPES::OrderValidity &validity=CONSTANTS::CMD_OrderValidity_DAY, const DATA_TYPES::ProductType &product=CONSTANTS::CMD_ProductType_DELIVERY, const UNSIGNED_LONG &price=0, const UNSIGNED_LONG &stopPrice=0)
 createNewOrder To create a New Order for an instrument More...
 
COMMON::OrderId * createNewOrderId (COMMON::Instrument *instrument, const API2::AccountDetail &accountDetail, const DATA_TYPES::OrderMode &mode)
 createNewOrderId Creates and Inserts a new OrderId Instance to the Instrument
for the requested OrderMode and sets the pointer to orderId More...
 
bool reqNewSingleOrder (DATA_TYPES::RiskStatus &riskStatus, COMMON::Instrument *instrument, SingleOrder *&order, COMMON::OrderId *orderId)
 reqNewSingleOrder To Send a new Order More...
 
bool reqReplaceOrder (DATA_TYPES::RiskStatus &riskStatus, COMMON::Instrument *instrument, SingleOrder *&order, COMMON::OrderId *orderId)
 reqReplaceOrder To send a replace Order More...
 
bool reqCancelOrder (DATA_TYPES::RiskStatus &riskStatus, COMMON::OrderId *orderId)
 reqCancelOrder To Cancel Order More...
 
void reqCancelAllOrders ()
 reqCancelAllOrders To cancel all Orders ( Confirmed or Partial Filled )
 
virtual void reqTerminateSquareOffStrategy ()
 reqTerminateSquareOffStrategy Called to Terminate strategy and Square-Off all Positions
Can be overriden
Default behaviour:
1) Cancel All Orders
2) Send Opposite Orders for closing Position
3) Terminate the strategy

 
virtual void reqTerminateStrategy (bool reqCancelAllOrders=true)
 reqTerminateStrategy Called to Terminate Strategy
Can be overriden
Default behaviour:
1) Cancel All Pending Orders
3) Terminate the strategy

 
void * reqStartAlgo (bool marketDataEventRequired, bool tradeTicksEventRequired)
 reqStartAlgo function call to Start the Strategy More...
 
void * reqStartOHLCAlgo ()
 reqStartOHLCAlgo function call to Start the Strategy listening to OHLC update events More...
 
bool reqProcessTradeTicks (bool &error, SYMBOL_ID symbolId)
 reqProcessTradeTicks More...
 
void reqRemoveInstrument (COMMON::Instrument *instrument)
 reqRemoveInstrument To remove Instrument from the context.
Removing will remove all the data relating the Instrument's Position More...
 
void reqRemoveAllInstruments ()
 reqRemoveAllInstruments This will remove all Instrument from the registered Instrument list
 
bool reqUpdateMarketData ()
 reqUpdateMarketData To manually update Market Feed for all registered Instruments.
Not required if marketDataEventRequired is set to be True while starting the strategy using API2::SGContext::reqStartAlgo() More...
 
bool reqUpdateMarketData (UNSIGNED_LONG symbolId)
 reqUpdateMarketData To manually update Market Feed for requested API2::DATA_TYPES::SYMBOL_ID.
Not required if marketDataEventRequired is set to be True while starting the strategy using API2::SGContext::reqStartAlgo() More...
 
void reqAddStrategyComment (DATA_TYPES::StrategyComment com)
 reqAddStrategyComment To set the current Startegy Comment Whenever a strategy Response is sent to frontend this will be the sent as the strategy Comment More...
 
void reqSendStrategyResponse (DATA_TYPES::ResponseType responseType, DATA_TYPES::RiskStatus riskStatus, DATA_TYPES::StrategyComment strategyComment=CONSTANTS::RSP_StrategyComment_MAX)
 reqSendStrategyResponse To send a Response to the frontend More...
 
void reqExitStrategy ()
 reqExitStrategy To exit a strategy terminates the Strategy thread and returns the StrategyDriver.
 
virtual bool reqQryTestSegment (const DATA_TYPES::ExchangeId &exch, const DATA_TYPES::SecurityType &securityType=CONSTANTS::CMD_SecurityType_MAX)
 reqQryTestSegment To know whether a given exchange segment is being used in the strategy or not More...
 
int reqQryClientID ()
 reqQryClientID To get ClientId More...
 
StrategyParametersreqQryStrategyParams ()
 reqQryStrategyParams To get StartegyParameters More...
 
COMMON::MktDatareqQryUpdateMarketData (SYMBOL_ID symbolId)
 reqQryUpdateMarketData This function call will return the Pointer to API2::COMMON::MktData structure after updating it.
Not required if marketDataEventRequired is set to be True while starting the strategy using API2::SGContext::reqStartAlgo() More...
 
COMMON::MktDatareqQryMarketData (SYMBOL_ID symbolId)
 reqQryMarketData This function call will return the Pointer to API2::COMMON::MktData structure
Here it will contain the last updated Market Snapshot More...
 
COMMON::OhlcQuotereqQryOHLCQuote (bool &error, SYMBOL_ID symbolId)
 reqQryOHLCQuote More...
 
SIGNED_LONG reqQryNetMarkToMarkPL ()
 reqQryNetMarkToMarkPL This function will return net Mark To Market Profit and Loss for the strategy( sum of all Instruments being traded) More...
 
SIGNED_LONG reqQryNetBookedPL ()
 reqQryNetBookedPL This function will return net Booked Profit and Loss for the strategy( sum of all Instruments being traded) More...
 
DATA_TYPES::SYMBOL_ID reqQrySymbolID (std::string instrumentName)
 reqQrySymbolID This function will return System Unique ID for the Instrument as API2::DATA_TYPES::SYMBOL_ID More...
 
std::list
< API2::COMMON::Instrument * > 
reqQryInstrumentList (UNSIGNED_LONG symbolId)
 reqQryInstrumentList To get list of all Instruments added for the requested SymbolId More...
 
API2::SingleOrderreqQryOrder (long clOrderId)
 reqQryOrder To get Pointer to Single Order using a clientOrderId More...
 
API2::DATA_TYPES::STRATEGY_ID reqQryStrategyId ()
 reqQryStrategyId To get StartegyId of current running Strategy. More...
 
DebugLogreqQryDebugLog ()
 reqQryDebugLog To get Pointer to the DebugLog Object used to dump debug messages.
Sample Usage:
DEBUG_MESSAGE(reqQryDebugLog()"<Message>"); More...
 
UNSIGNED_LONG reqQryPendingQty (COMMON::Instrument *instrument, DATA_TYPES::OrderMode mode)
 reqQryPendingQty To get Pending Quantity of an Instrument More...
 
DATA_TYPES::QTY reqQryPendingQty (COMMON::OrderId *orderId)
 reqQryPendingQty To get Pending Quantity of requested Order as orderId More...
 
DATA_TYPES::CLORDER_ID reqQryClientOrderId (COMMON::OrderId *orderId)
 reqQryClientOrderId To get ClientOrderId of requested Order More...
 
DATA_TYPES::OrderStatus reqQryOrderStatus (COMMON::OrderId *orderId)
 reqQryOrderStatus To get OrderStatus of requested Order More...
 
DATA_TYPES::String reqQryExchangeOrderId (COMMON::OrderId *orderId)
 reqQryExchangeOrderId To get Exchange OrderId of requested Order More...
 
DATA_TYPES::String getStrConfirmation (const OrderConfirmation &confirmation)
 getStrConfirmation. Prints OrderConfirmation fields More...
 
DATA_TYPES::String getStrSingleOrder (SingleOrder *order)
 getStrSingleOrder. Prints Single Order fields More...
 
DATA_TYPES::String getStrOrderId (const COMMON::OrderId *orderId)
 getStrOrderId. Prints OrderId Fields More...
 
virtual void onCMDAdminCommand (DATA_TYPES::CommandCategory command)
 onCMDAdminCommand Called when ever a command from frontend is issued. More...
 
virtual void onCMDDisconnection (const DATA_TYPES::CommandCategory &command)
 onCMDDisconnection Called whenever a disconnection is received disconnected entity to be determined from CommandCategory More...
 
virtual void onCMDModifyStrategy (AbstractUserParams *newParams)=0
 onCMDModifyStrategy Called when strategy modify command is received
 
virtual void onCMDTerminateStartegy ()
 onCMDTerminateStartegy Called when strategy receives Terminate Command from Frontend
 
virtual void onCMDTerminateSqOffStrategy ()
 onCMDTerminateSqOffStrategy Called when strategy receives Terminate SqOff Command from Frontend
 
virtual void onCMDPauseStartegy ()
 onCMDPauseStartegy Called when strategy receives Pause Command from Frontend
 
virtual void onCMDRunStrategy ()
 onCMDRunStrategy Called when strategy receives Run Command from Frontend
 
virtual void onCMDInit ()
 OnCMDInit To Set Initial state of the algo.
 
virtual void onDefaultEvent ()
 onDefaultEvent Called as an event if Not configured to received marketData Event while Running Algo
 
virtual void onMarketDataEvent (UNSIGNED_LONG symbolId)
 onMarketDataEvent Called if Configured to received marketData Event while Running Algo More...
 
virtual void onOhlcTimeOutEvent ()
 onOhlcTimeOutEvent Called if Configured to received OHLC update Event while Running Algo
Callback is provided each time the OHLC Data is updated
 
virtual void onTradeTickEvent (COMMON::TradeTick tradeTick)
 onTradeTickEvent Called if Configured to received Trade Ticks update Event while Running Algo
Callback is provided each time the Trade Tick is received through the TBT Server This event is specific to NSE-TBT Trade Tick currently
 
virtual void onProcessOrderConfirmation (OrderConfirmation &confirmation)
 onProcessOrderConfirmation Call back after OrderConfirmation Processing is done
Not necessary to override this
To be overridden only If any additional Processing is reqd at the algo end More...
 
virtual void onConfirmed (OrderConfirmation &confirmation, COMMON::OrderId *orderId)
 onConfirmed Call back when a new Order gets confirmed by exchange. More...
 
virtual void onReplaceRejected (OrderConfirmation &confirmation, COMMON::OrderId *orderId)
 onReplaceRejected Call back when a replace order gets rejected by the exchange More...
 
virtual void onCanceled (OrderConfirmation &confirmation, COMMON::OrderId *orderId)
 onCanceled Call back when a cancel order gets accepted by the exchange More...
 
virtual void onCancelRejected (OrderConfirmation &confirmation, COMMON::OrderId *orderId)
 onCancelRejected Call back when a cancel order gets rejected by the exchange More...
 
virtual void onReplaced (OrderConfirmation &confirmation, COMMON::OrderId *orderId)
 onReplaced Call back when a Order gets replaced sucessfully at the exchange. More...
 
virtual void onNewReject (OrderConfirmation &confirmation, COMMON::OrderId *orderId)
 onNewRejected Call back when a new order gets rejected by the exchange More...
 
virtual void onIOCCanceled (OrderConfirmation &Confirmation, COMMON::OrderId *orderId)
 onIOCCanceled Call back when an IOC order gets canceled the exchange More...
 
virtual void onFilled (OrderConfirmation &confirmation, COMMON::OrderId *orderId)
 onFilled Call back when an order gets filled at the exchange More...
 
virtual void onPartialFill (OrderConfirmation &confirmation, COMMON::OrderId *orderId)
 onPartialFill Call back when an order gets partially filled at the exchange More...
 
virtual void onMarketToLimit (API2::OrderConfirmation &confirmation, API2::COMMON::OrderId *orderId)
 onMarketToLimit Call back when Orderstatus changes from Market To Limit by exchange More...
 
virtual void onFrozen (API2::OrderConfirmation &confirmation, API2::COMMON::OrderId *orderId)
 onFrozen Call back when an order gets frozen by exchange More...
 

Detailed Description

The SGContext class The main class to be inherited for creating a new Strategy.

Constructor & Destructor Documentation

API2::SGContext::SGContext ( StrategyParameters params,
const std::string  sgName 
)

SGContext Constructor.

Parameters
paramsAPI2::StrategyParameters
sgNameUnique String for Strategy Name

Member Function Documentation

COMMON::Instrument* API2::SGContext::createNewInstrument ( UNSIGNED_LONG  symbolId,
bool  regMktData,
bool  useSnapShot = false,
bool  useOhlc = true 
)

createNewInstrument To add a new Instrument in the strategy
The Pointer to the added Instrument is set in instrument passed as reference

Parameters
symbolIdSystem Unique ID for the Instrument as API2::DATA_TYPES::SYMBOL_ID
regMktDataset True to register for Market Data for the Instrument
useSnapShotSet True if Snapshot Feed is to be used and False to use TBT-Feed
useOhlcSet True if OHLC Heed is also required
Exceptions
MarketDataSubscriptionFailedException
Returns
COMMON::Instrument Pointer
COMMON::Instrument* API2::SGContext::createNewInstrument ( const std::string &  instrumentName,
bool  regMktData = false,
bool  useSnapShot = true,
bool  useOhlc = false 
)

createNewInstrument To add a new Instrument in the strategy
The Pointer to the added Instrument is set in instrument passed as reference

Parameters
instrumentNameInstrument Name Format: [ExchangeName] [Symbol] [Expiry(YYYYMMDD)] [StrikePrice] [C/P(For Call/Put)] Example: Cash Segment: NSE RELIANCE Futures Segment: NSE RELIANCE 20140828 Options Segment: NSE RELIANCE 20140828 980.00 C
regMktDataset True to register for Market Data for the Instrument
useSnapShotSet True if Snapshot Feed is to be used and False to use TBT-Feed
useOhlcSet True if OHLC Heed is also required
Returns
COMMON::Instrument Pointer
Exceptions
MarketDataSubscriptionFailedException
SingleOrder* API2::SGContext::createNewOrder ( COMMON::Instrument instrument,
const UNSIGNED_LONG &  qty = 0,
const UNSIGNED_LONG &  discQty = 0,
const DATA_TYPES::OrderMode &  mode = CONSTANTS::CMD_OrderMode_BUY,
const DATA_TYPES::OrderType &  type = CONSTANTS::CMD_OrderType_LIMIT,
const DATA_TYPES::OrderValidity &  validity = CONSTANTS::CMD_OrderValidity_DAY,
const DATA_TYPES::ProductType &  product = CONSTANTS::CMD_ProductType_DELIVERY,
const UNSIGNED_LONG &  price = 0,
const UNSIGNED_LONG &  stopPrice = 0 
)

createNewOrder To create a New Order for an instrument

Parameters
orderReference to Pointer of API2::SingleOrder Pointer to created object will be set into this. For creating an Order
instrumentPointer to the Instrument for which a new SingleOrder is to be created
qtyOrder Quantity
discQtyDiclosed Order Quantity
modeOrderMode as API2::CONSTANTS::CMD_OrderMode_BUY or API2::CONSTANTS::CMD_OrderMode_SELL
typeOrderType as API2::DATA_TYPES::OrderType
validityOrder Validity
productProduct
pricePrice
stopPriceStop Price
Returns
SingleOrder Pointer
COMMON::OrderId* API2::SGContext::createNewOrderId ( COMMON::Instrument instrument,
const API2::AccountDetail accountDetail,
const DATA_TYPES::OrderMode &  mode 
)

createNewOrderId Creates and Inserts a new OrderId Instance to the Instrument
for the requested OrderMode and sets the pointer to orderId

Parameters
instrumentshould be valid and Not null
modeshould be valid API2::CONSTANTS::CMD_OrderMode_BUY or API2::CONSTANTS::CMD_OrderMode_SELL
Returns
COMMON::OrderId Ptr
DATA_TYPES::String API2::SGContext::getStrConfirmation ( const OrderConfirmation confirmation)

getStrConfirmation. Prints OrderConfirmation fields

Parameters
confirmation
DATA_TYPES::String API2::SGContext::getStrOrderId ( const COMMON::OrderId *  orderId)

getStrOrderId. Prints OrderId Fields

Parameters
orderId
DATA_TYPES::String API2::SGContext::getStrSingleOrder ( SingleOrder order)

getStrSingleOrder. Prints Single Order fields

Parameters
order
virtual void API2::SGContext::onCanceled ( OrderConfirmation confirmation,
COMMON::OrderId *  orderId 
)
inlinevirtual

onCanceled Call back when a cancel order gets accepted by the exchange

Parameters
confirmationContains the information received from Exchange
orderIdPointer to the API2::COMMON::OrderId type
virtual void API2::SGContext::onCancelRejected ( OrderConfirmation confirmation,
COMMON::OrderId *  orderId 
)
inlinevirtual

onCancelRejected Call back when a cancel order gets rejected by the exchange

Parameters
confirmationContains the information received from Exchange
orderIdPointer to the API2::COMMON::OrderId type
virtual void API2::SGContext::onCMDAdminCommand ( DATA_TYPES::CommandCategory  command)
inlinevirtual

onCMDAdminCommand Called when ever a command from frontend is issued.

Parameters
command
virtual void API2::SGContext::onCMDDisconnection ( const DATA_TYPES::CommandCategory &  command)
virtual

onCMDDisconnection Called whenever a disconnection is received disconnected entity to be determined from CommandCategory

Parameters
command
virtual void API2::SGContext::onConfirmed ( OrderConfirmation confirmation,
COMMON::OrderId *  orderId 
)
inlinevirtual

onConfirmed Call back when a new Order gets confirmed by exchange.

Parameters
confirmationContains the information received from Exchange
orderIdPointer to the API2::COMMON::OrderId type
virtual void API2::SGContext::onFilled ( OrderConfirmation confirmation,
COMMON::OrderId *  orderId 
)
inlinevirtual

onFilled Call back when an order gets filled at the exchange

Parameters
confirmationContains the information received from Exchange
orderIdPointer to the API2::COMMON::OrderId type
virtual void API2::SGContext::onFrozen ( API2::OrderConfirmation confirmation,
API2::COMMON::OrderId *  orderId 
)
inlinevirtual

onFrozen Call back when an order gets frozen by exchange

Parameters
confirmationContains the information received from Exchange
orderIdPointer to the API2::COMMON::OrderId type
virtual void API2::SGContext::onIOCCanceled ( OrderConfirmation Confirmation,
COMMON::OrderId *  orderId 
)
inlinevirtual

onIOCCanceled Call back when an IOC order gets canceled the exchange

Parameters
confirmationContains the information received from Exchange
orderIdPointer to the API2::COMMON::OrderId type
virtual void API2::SGContext::onMarketDataEvent ( UNSIGNED_LONG  symbolId)
virtual

onMarketDataEvent Called if Configured to received marketData Event while Running Algo

Parameters
symbolIdSymbolId of the Instrument that received marketData SymbolId should be subscribed for Market Data while initializing
virtual void API2::SGContext::onMarketToLimit ( API2::OrderConfirmation confirmation,
API2::COMMON::OrderId *  orderId 
)
inlinevirtual

onMarketToLimit Call back when Orderstatus changes from Market To Limit by exchange

Parameters
confirmationContains the information received from Exchange
orderIdPointer to the API2::COMMON::OrderId type
virtual void API2::SGContext::onNewReject ( OrderConfirmation confirmation,
COMMON::OrderId *  orderId 
)
inlinevirtual

onNewRejected Call back when a new order gets rejected by the exchange

Parameters
confirmationContains the information received from Exchange
orderIdPointer to the API2::COMMON::OrderId type
virtual void API2::SGContext::onPartialFill ( OrderConfirmation confirmation,
COMMON::OrderId *  orderId 
)
inlinevirtual

onPartialFill Call back when an order gets partially filled at the exchange

Parameters
confirmationContains the information received from Exchange
orderIdPointer to the API2::COMMON::OrderId type
virtual void API2::SGContext::onProcessOrderConfirmation ( OrderConfirmation confirmation)
inlinevirtual

onProcessOrderConfirmation Call back after OrderConfirmation Processing is done
Not necessary to override this
To be overridden only If any additional Processing is reqd at the algo end

Parameters
confirmationReference to the API2::OrderConformation
virtual void API2::SGContext::onReplaced ( OrderConfirmation confirmation,
COMMON::OrderId *  orderId 
)
inlinevirtual

onReplaced Call back when a Order gets replaced sucessfully at the exchange.

Parameters
confirmationContains the information received from Exchange
orderIdPointer to the API2::COMMON::OrderId type
virtual void API2::SGContext::onReplaceRejected ( OrderConfirmation confirmation,
COMMON::OrderId *  orderId 
)
inlinevirtual

onReplaceRejected Call back when a replace order gets rejected by the exchange

Parameters
confirmationContains the information received from Exchange
orderIdPointer to the API2::COMMON::OrderId type
void API2::SGContext::reqAddStrategyComment ( DATA_TYPES::StrategyComment  com)

reqAddStrategyComment To set the current Startegy Comment Whenever a strategy Response is sent to frontend this will be the sent as the strategy Comment

Parameters
com
bool API2::SGContext::reqCancelOrder ( DATA_TYPES::RiskStatus &  riskStatus,
COMMON::OrderId *  orderId 
)

reqCancelOrder To Cancel Order

Parameters
riskStatuspassed by reference This is the risk status for sending Canceled Order
orderId
Returns
bool API2::SGContext::reqNewSingleOrder ( DATA_TYPES::RiskStatus &  riskStatus,
COMMON::Instrument instrument,
SingleOrder *&  order,
COMMON::OrderId *  orderId 
)

reqNewSingleOrder To Send a new Order

Parameters
riskStatus
instrument
order
orderId
Returns
bool API2::SGContext::reqProcessTradeTicks ( bool &  error,
SYMBOL_ID  symbolId 
)

reqProcessTradeTicks

Parameters
error
symbolId
Returns
int API2::SGContext::reqQryClientID ( )

reqQryClientID To get ClientId

Returns
DATA_TYPES::CLORDER_ID API2::SGContext::reqQryClientOrderId ( COMMON::OrderId *  orderId)

reqQryClientOrderId To get ClientOrderId of requested Order

Parameters
orderId
Returns
DebugLog* API2::SGContext::reqQryDebugLog ( )

reqQryDebugLog To get Pointer to the DebugLog Object used to dump debug messages.
Sample Usage:
DEBUG_MESSAGE(reqQryDebugLog()"<Message>");

Returns
DATA_TYPES::String API2::SGContext::reqQryExchangeOrderId ( COMMON::OrderId *  orderId)

reqQryExchangeOrderId To get Exchange OrderId of requested Order

Parameters
orderId
Returns
std::list<API2::COMMON::Instrument *> API2::SGContext::reqQryInstrumentList ( UNSIGNED_LONG  symbolId)

reqQryInstrumentList To get list of all Instruments added for the requested SymbolId

Parameters
symbolIdSystem Unique Id for the Instrument
Returns
COMMON::MktData* API2::SGContext::reqQryMarketData ( SYMBOL_ID  symbolId)

reqQryMarketData This function call will return the Pointer to API2::COMMON::MktData structure
Here it will contain the last updated Market Snapshot

Parameters
symbolId
Returns
SIGNED_LONG API2::SGContext::reqQryNetBookedPL ( )

reqQryNetBookedPL This function will return net Booked Profit and Loss for the strategy( sum of all Instruments being traded)

Returns
SIGNED_LONG API2::SGContext::reqQryNetMarkToMarkPL ( )

reqQryNetMarkToMarkPL This function will return net Mark To Market Profit and Loss for the strategy( sum of all Instruments being traded)

Returns
COMMON::OhlcQuote* API2::SGContext::reqQryOHLCQuote ( bool &  error,
SYMBOL_ID  symbolId 
)

reqQryOHLCQuote

Parameters
error
symbolId
Returns
API2::SingleOrder* API2::SGContext::reqQryOrder ( long  clOrderId)

reqQryOrder To get Pointer to Single Order using a clientOrderId

Parameters
clOrderId
Returns
DATA_TYPES::OrderStatus API2::SGContext::reqQryOrderStatus ( COMMON::OrderId *  orderId)

reqQryOrderStatus To get OrderStatus of requested Order

Parameters
orderId
Returns
UNSIGNED_LONG API2::SGContext::reqQryPendingQty ( COMMON::Instrument instrument,
DATA_TYPES::OrderMode  mode 
)

reqQryPendingQty To get Pending Quantity of an Instrument

Parameters
instrumentAPI2::COMMON::Instrument
modeOrdermode as API2::CONSTANTS::CMD_OrderMode_BUY or API2::CONSTANTS::CMD_OrderMode_SELL
Returns
DATA_TYPES::QTY API2::SGContext::reqQryPendingQty ( COMMON::OrderId *  orderId)

reqQryPendingQty To get Pending Quantity of requested Order as orderId

Parameters
orderId
Returns
API2::DATA_TYPES::STRATEGY_ID API2::SGContext::reqQryStrategyId ( )

reqQryStrategyId To get StartegyId of current running Strategy.

Returns
StrategyParameters* API2::SGContext::reqQryStrategyParams ( )

reqQryStrategyParams To get StartegyParameters

Returns
DATA_TYPES::SYMBOL_ID API2::SGContext::reqQrySymbolID ( std::string  instrumentName)

reqQrySymbolID This function will return System Unique ID for the Instrument as API2::DATA_TYPES::SYMBOL_ID

Parameters
instrumentNameInstrument Name Format: [ExchangeName] [Symbol] [Expiry(YYYYMMDD)] [StrikePrice] [C/P(For Call/Put)] Example: Cash Segment: NSE RELIANCE Futures Segment: NSE RELIANCE 20140828 Options Segment: NSE RELIANCE 20140828 980.00 C
virtual bool API2::SGContext::reqQryTestSegment ( const DATA_TYPES::ExchangeId &  exch,
const DATA_TYPES::SecurityType &  securityType = CONSTANTS::CMD_SecurityType_MAX 
)
virtual

reqQryTestSegment To know whether a given exchange segment is being used in the strategy or not

Parameters
exchThe DATA_TYPES::ExchangeId
securityTypeThe DATA_TYPES::SecurityType
Returns
COMMON::MktData* API2::SGContext::reqQryUpdateMarketData ( SYMBOL_ID  symbolId)

reqQryUpdateMarketData This function call will return the Pointer to API2::COMMON::MktData structure after updating it.
Not required if marketDataEventRequired is set to be True while starting the strategy using API2::SGContext::reqStartAlgo()

Parameters
symbolIdSymbolId for which MarketData is required
Returns
void API2::SGContext::reqRemoveInstrument ( COMMON::Instrument instrument)

reqRemoveInstrument To remove Instrument from the context.
Removing will remove all the data relating the Instrument's Position

Parameters
instrument
bool API2::SGContext::reqReplaceOrder ( DATA_TYPES::RiskStatus &  riskStatus,
COMMON::Instrument instrument,
SingleOrder *&  order,
COMMON::OrderId *  orderId 
)

reqReplaceOrder To send a replace Order

Parameters
riskStatus
instrument
order
updateQuantity
orderId
Returns
void API2::SGContext::reqSendStrategyResponse ( DATA_TYPES::ResponseType  responseType,
DATA_TYPES::RiskStatus  riskStatus,
DATA_TYPES::StrategyComment  strategyComment = CONSTANTS::RSP_StrategyComment_MAX 
)

reqSendStrategyResponse To send a Response to the frontend

Parameters
responseTypethe response Type as DATA_TYPES::ResponseType
riskStatusthe Risk Status as DATA_TYPES::RiskStatus
strategyCommentthe Strategy Comment as DATA_TYPES::StrategyComment
void* API2::SGContext::reqStartAlgo ( bool  marketDataEventRequired,
bool  tradeTicksEventRequired 
)

reqStartAlgo function call to Start the Strategy

Parameters
marketDataEventRequiredSet True to register for call-backs on Market-Data Event on registered Instruments
tradeTicksEventRequiredSet True to register for call-backs on Trade Tick Events on registered Instruments
Returns
void* API2::SGContext::reqStartOHLCAlgo ( )

reqStartOHLCAlgo function call to Start the Strategy listening to OHLC update events

Returns
bool API2::SGContext::reqUpdateMarketData ( )

reqUpdateMarketData To manually update Market Feed for all registered Instruments.
Not required if marketDataEventRequired is set to be True while starting the strategy using API2::SGContext::reqStartAlgo()

Returns
True if there is a new updation in Market Data. False if no new updation.
bool API2::SGContext::reqUpdateMarketData ( UNSIGNED_LONG  symbolId)

reqUpdateMarketData To manually update Market Feed for requested API2::DATA_TYPES::SYMBOL_ID.
Not required if marketDataEventRequired is set to be True while starting the strategy using API2::SGContext::reqStartAlgo()

Returns
True if there is a new updation in Market Data. False if no new updation.

The documentation for this class was generated from the following file: