public interface OrderContext
Modifier and Type | Method and Description |
---|---|
void |
buy(Instrument instr,
int qty)
Convenience Method: Places a BUY order for the given instrument at market price.
|
void |
buy(int qty)
Convenience Method: Places a BUY order for the current instrument at market price.
|
double |
calcPnl(float entryPrice,
float exitPrice,
int qty)
Convenience Method.
|
double |
calcPnl(float entryPrice,
int qty)
Convenience Method.
|
void |
cancelOrders()
Cancels all of the open orders for this strategy.
|
void |
cancelOrders(java.util.List<Order> orders)
Use this method to cancel one or more existing orders.
|
void |
cancelOrders(Order... orders)
Use this method to cancel one or more existing orders.
|
void |
closeAccountAtMarket()
Closes the position held by the selected account.
|
void |
closeAtMarket()
Closes the position held by this strategy.
|
double |
convertToBaseCurrency(double pnl)
Converts the given amount to the amount in the base currency using the instrument associated with this context.
|
double |
convertToBaseCurrency(Instrument instr,
double pnl)
Converts the given amount to the amount in the base currency.
|
Order |
createLimitOrder(Enums.OrderAction action,
Enums.TIF tif,
int qty,
float limitPrice)
Creates a new 'Limit' order.
|
Order |
createLimitOrder(Instrument instr,
Enums.OrderAction action,
Enums.TIF tif,
int qty,
float limitPrice)
Creates a new 'Limit' order.
|
Order |
createLimitOrder(Instrument instr,
java.lang.Object refId,
Enums.OrderAction action,
Enums.TIF tif,
int qty,
float limitPrice)
Creates a new 'Limit' order using the given instrument.
|
Order |
createLimitOrder(java.lang.Object refId,
Enums.OrderAction action,
Enums.TIF tif,
int qty,
float limitPrice)
Creates a new 'Limit' order using the current instrument.
|
Order |
createMarketOrder(Enums.OrderAction action,
int qty)
Creates a new 'Market' order.
|
Order |
createMarketOrder(Instrument instr,
Enums.OrderAction action,
int qty)
Creates a new 'Market' order.
|
Order |
createMarketOrder(Instrument instr,
java.lang.Object refId,
Enums.OrderAction action,
int qty)
Creates a new 'Market' order using the given instrument.
|
Order |
createMarketOrder(java.lang.Object refId,
Enums.OrderAction action,
int qty)
Creates a new 'Market' order using the current instrument.
|
Order |
createStopOrder(Enums.OrderAction action,
Enums.TIF tif,
int qty,
float stopPrice)
Creates a new 'Stop' order.
|
Order |
createStopOrder(Instrument instr,
Enums.OrderAction action,
Enums.TIF tif,
int qty,
float stopPrice)
Creates a new 'Stop' order.
|
Order |
createStopOrder(Instrument instr,
java.lang.Object refId,
Enums.OrderAction action,
Enums.TIF tif,
int qty,
float stopPrice)
Creates a new 'Stop' order using the given instrument.
|
Order |
createStopOrder(java.lang.Object refId,
Enums.OrderAction action,
Enums.TIF tif,
int qty,
float stopPrice)
Creates a new 'Stop' order using the current instrument.
|
float |
getAccountAvgEntryPrice()
Gets the average entry price for the current position on the selected account.
|
int |
getAccountPosition()
Gets the current open position for the account.
|
float |
getAccountUnrealizedPnL()
Gets the average entry price for the current position on the selected account.
|
java.util.List<Order> |
getActiveOrders()
Gets all of the active orders that are associated with this strategy.
|
float |
getAvgEntryPrice()
Gets the average entry price for the current position.
|
java.lang.String |
getBaseCurrency()
Gets the symbol for the base currency.
|
double |
getCashBalance()
Gets the current cash balance for the account.
|
long |
getCurrentTime()
Gets the current time.
|
DataContext |
getDataContext()
Gets the data context associated with this strategy.
|
Defaults |
getDefaults()
Defaults defined by the system.
|
java.util.List<Execution> |
getExecutions()
Gets the list of executed orders that have occurred since this strategy was activated.
|
Instrument |
getInstrument()
Gets the instrument associated with the data provided in this context.
|
int |
getPosition()
Gets the current open position for this strategy.
|
double |
getRealizedPnL()
Gets the realized PnL (profit/loss) for the current 'leg' of the strategy.
|
double |
getTotalRealizedPnL()
Gets the total realized pnl (profit/loss) since this strategy was opened (or last reset).
|
double |
getUnrealizedPnL()
Gets the PnL for the open position.
|
void |
sell(Instrument instr,
int qty)
Convenience Method: Places a SELL order for the given instrument at market price.
|
void |
sell(int qty)
Convenience Method: Places a SELL order for the current instrument at market price.
|
void |
submitOrders(java.util.List<Order> orders)
Use this method to submit one or more orders to the broker.
|
void |
submitOrders(Order... orders)
Use this method to submit one or more orders to the broker.
|
boolean |
supportsHedging()
Determines if this account (broker) supports hedging.
|
DataContext getDataContext()
Instrument getInstrument()
Defaults getDefaults()
long getCurrentTime()
int getPosition()
float getAvgEntryPrice()
double getTotalRealizedPnL()
double getRealizedPnL()
double getUnrealizedPnL()
int getAccountPosition()
float getAccountAvgEntryPrice()
float getAccountUnrealizedPnL()
double getCashBalance()
java.util.List<Execution> getExecutions()
java.lang.String getBaseCurrency()
double convertToBaseCurrency(double pnl)
pnl
- profit/lossdouble convertToBaseCurrency(Instrument instr, double pnl)
instr
- instrumentpnl
- profit/lossdouble calcPnl(float entryPrice, int qty)
entryPrice
- qty
- double calcPnl(float entryPrice, float exitPrice, int qty)
entryPrice
- exitPrice
- qty
- boolean supportsHedging()
java.util.List<Order> getActiveOrders()
void buy(Instrument instr, int qty)
instr
- instrumentqty
- number of shares/units to buyvoid buy(int qty)
qty
- number of shares/units to buyvoid sell(Instrument instr, int qty)
instr
- instrumentqty
- number of shares/units to sellvoid sell(int qty)
qty
- number of shares/units to sellvoid closeAtMarket()
void closeAccountAtMarket() throws MException
MException
void submitOrders(Order... orders)
orders
- orders to submitvoid submitOrders(java.util.List<Order> orders)
orders
- list of orders to submitvoid cancelOrders(Order... orders)
orders
- list of orders to cancelvoid cancelOrders(java.util.List<Order> orders)
orders
- list of orders to cancelvoid cancelOrders()
Order createMarketOrder(Enums.OrderAction action, int qty)
action
- order action (buy/sell)qty
- quantity of shares/unitsOrder createMarketOrder(Instrument instr, Enums.OrderAction action, int qty)
instr
- instrumentaction
- order action (buy/sell)qty
- quantity of shares/unitsOrder createLimitOrder(Enums.OrderAction action, Enums.TIF tif, int qty, float limitPrice)
action
- order action (buy/sell)tif
- time in forceqty
- quantity of shares/unitslimitPrice
- Order createLimitOrder(Instrument instr, Enums.OrderAction action, Enums.TIF tif, int qty, float limitPrice)
instr
- instrumentaction
- order action (buy/sell)tif
- time in forceqty
- quantity of shares/unitslimitPrice
- Order createStopOrder(Enums.OrderAction action, Enums.TIF tif, int qty, float stopPrice)
action
- order action (buy/sell)tif
- time in forceqty
- quantity of shares/unitsstopPrice
- Order createStopOrder(Instrument instr, Enums.OrderAction action, Enums.TIF tif, int qty, float stopPrice)
instr
- instrumentaction
- order action (buy/sell)tif
- time in forceqty
- quantity of shares/unitsstopPrice
- Order createMarketOrder(java.lang.Object refId, Enums.OrderAction action, int qty)
refId
- reference idaction
- order action (buy/sell)qty
- quantityOrder createMarketOrder(Instrument instr, java.lang.Object refId, Enums.OrderAction action, int qty)
instr
- instrumentrefId
- reference idaction
- order action (buy/sell)qty
- quantityOrder createLimitOrder(java.lang.Object refId, Enums.OrderAction action, Enums.TIF tif, int qty, float limitPrice)
refId
- reference idaction
- order action (buy/sell)qty
- quantitylimitPrice
- limit priceOrder createLimitOrder(Instrument instr, java.lang.Object refId, Enums.OrderAction action, Enums.TIF tif, int qty, float limitPrice)
instr
- instrumentrefId
- reference idaction
- order action (buy/sell)qty
- quantitylimitPrice
- limit priceOrder createStopOrder(java.lang.Object refId, Enums.OrderAction action, Enums.TIF tif, int qty, float stopPrice)
refId
- reference idaction
- order action (buy/sell)qty
- quantitystopPrice
- stop priceOrder createStopOrder(Instrument instr, java.lang.Object refId, Enums.OrderAction action, Enums.TIF tif, int qty, float stopPrice)
instr
- instrumentrefId
- reference idaction
- order action (buy/sell)qty
- quantitystopPrice
- stop price