SeSim API (Groovy)
The sesim object provides trading simulation functions for Groovy scripts.
Constants
- BUYLIMIT - Buy limit order type
- SELLIMIT - Sell limit order type
- SELL - Market sell order type
- BUY - Market buy order type
- STOPLOSS - Stop-loss order type
Order Management
-
createOrder(byte type, double vol, double limit, double stop)
Create a new order. Returns an Order object.
type: Can be one of BUY,SELL,BUYLIMIT,SELLIMIT. STOPLOSS.
vol: Number of shares to trade
limit: limit price, must be set if type ist BUYLIMIT OR SELLLIMIT.
- cancleOrder(Order o)
Cancel an existing order. Returns true if successful.
- getLastQuote()
Returns the last Quote object.
- getLastPrice()
Returns the price from the last quote.
Logging
- logInfo(String msg, Object... args) - Log an info message
- logError(String msg, Object... args) - Log an error message
Event Scheduling
- scheduleOnce(String groovyFun, long timer)
Schedule a one-time call to a Groovy function after timer milliseconds.
- scheduleOnPriceAbove(String groovyFun, double price)
Call a Groovy function when the price goes above price. Returns a GroovyPriceEvent.
- cancelSchedulePriceAboce(GroovyPriceEvent e)
Cancel a scheduled "price above" event.
- scheduleOnPriceBelow(String groovyFun, double price)
Call a Groovy function when the price goes below price. Returns a GroovyPriceEvent.
- cancelSchedulePriceBelow(GroovyPriceEvent e)
Cancel a scheduled "price below" event.
Random Numbers
- getRandom(long a, long b) - Returns a random long between a and b.
- getRandom(double a, double b) - Returns a random double between a and b.
Status
- setStatus(String s, Object... args) - Set the current status message.
- getName() - Returns the name of the trader.
Account Updates
- onAccountUpdate(String groovyFun)
Register a Groovy function to be called whenever the account is updated.
The function receives the Order that triggered the update.