Package com.strategyquant.tradinglib
Class Trader
java.lang.Object
com.strategyquant.tradinglib.Trader
Trader class contains methods to open new order, get list of all live orders, etc.
Created orders are not immediately executed, they have to be sent to the appropriate execution engine.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionBuy.Buy limit.Buy stop.BuyStopLimit(String symbol, double price)
Buy stop limit.void
destroy()
Destroy.void
evaluateActionListeners(int updateEventType, StrategyBase strategyBase)
Evaluate action listeners.void
eventBarUpdated(int eventType)
Event bar updated.boolean
Fill at real ask bid price.double
Gets the account balance.double
Gets the account equity.int
Gets the ambiguous trades.getHistoryOrder(int index)
Gets the history order.Gets the history orders.int
Gets the history orders count.double
Gets the initial balance.Gets the money management method.getName()
Gets the name.getOpenOrder(int index, boolean includeClosingOrders)
Gets the open order.int
getOpenOrdersCount(boolean includeClosingOrders)
Gets the open orders count.Gets the setup name.Gets the strategy.Gets the strategy name.it.unimi.dsi.fastutil.longs.Long2FloatRBTreeMap
Gets the worst daily equity.void
initialize(com.strategyquant.tradinglib.strategy.MarketData marketData)
Initialize.Open.Open.refuseOrder(ILiveOrder order, String message)
Refuse order.Sell.Sell limit.Sell stop.SellStopLimit(String symbol, double price)
Sell stop limit.send(ILiveOrder order, byte action, byte additionalFlag, int syncType, com.strategyquant.tradinglib.event.ITradingEventListener orderEventListener)
Send.send(ILiveOrder order, byte action, int syncType, com.strategyquant.tradinglib.event.ITradingEventListener orderEventListener)
Send.void
setSettings(SettingsMap settings)
Sets the settings.void
setStrategy(StrategyBase strategy)
Sets the strategy.boolean
Supports duplicate trades.
-
Constructor Details
-
Trader
public Trader(String name, com.strategyquant.tradinglib.execution.IExecutionEngine executionEngine)Instantiates a new trader.- Parameters:
name
- the nameexecutionEngine
- the execution engine
-
-
Method Details
-
setStrategy
Sets the strategy.- Parameters:
strategy
- the new strategy
-
getStrategy
Gets the strategy.- Returns:
- the strategy
-
getName
Gets the name.- Returns:
- the name
-
initialize
public void initialize(com.strategyquant.tradinglib.strategy.MarketData marketData)Initialize.- Parameters:
marketData
- the market data
-
eventBarUpdated
public void eventBarUpdated(int eventType)Event bar updated.- Parameters:
eventType
- the event type
-
Open
Open.- Parameters:
tradeType
- the trade typesymbol
- the symbol- Returns:
- the i live order
- Throws:
TradingException
- the trading exception
-
Open
Open.- Parameters:
tradeType
- the trade typesymbol
- the symbolprice
- the price- Returns:
- the i live order
- Throws:
TradingException
- the trading exception
-
Buy
Buy.- Parameters:
symbol
- the symbol- Returns:
- the i live order
- Throws:
TradingException
- the trading exception
-
Sell
Sell.- Parameters:
symbol
- the symbol- Returns:
- the i live order
- Throws:
TradingException
- the trading exception
-
BuyLimit
Buy limit.- Parameters:
symbol
- the symbolprice
- the price- Returns:
- the i live order
- Throws:
TradingException
- the trading exception
-
SellLimit
Sell limit.- Parameters:
symbol
- the symbolprice
- the price- Returns:
- the i live order
- Throws:
TradingException
- the trading exception
-
BuyStop
Buy stop.- Parameters:
symbol
- the symbolprice
- the price- Returns:
- the i live order
- Throws:
TradingException
- the trading exception
-
SellStop
Sell stop.- Parameters:
symbol
- the symbolprice
- the price- Returns:
- the i live order
- Throws:
TradingException
- the trading exception
-
BuyStopLimit
Buy stop limit.- Parameters:
symbol
- the symbolprice
- the price- Returns:
- the i live order
- Throws:
TradingException
- the trading exception
-
SellStopLimit
Sell stop limit.- Parameters:
symbol
- the symbolprice
- the price- Returns:
- the i live order
- Throws:
TradingException
- the trading exception
-
send
public ILiveOrder send(ILiveOrder order, byte action, int syncType, com.strategyquant.tradinglib.event.ITradingEventListener orderEventListener) throws TradingExceptionSend.- Parameters:
order
- the orderaction
- the actionsyncType
- the sync typeorderEventListener
- the order event listener- Returns:
- the i live order
- Throws:
TradingException
- the trading exception
-
send
public ILiveOrder send(ILiveOrder order, byte action, byte additionalFlag, int syncType, com.strategyquant.tradinglib.event.ITradingEventListener orderEventListener) throws TradingExceptionSend.- Parameters:
order
- the orderaction
- the actionadditionalFlag
- the additional flagsyncType
- the sync typeorderEventListener
- the order event listener- Returns:
- the i live order
- Throws:
TradingException
- the trading exception
-
refuseOrder
Refuse order.- Parameters:
order
- the ordermessage
- the message- Returns:
- the i live order
-
getHistoryOrders
Gets the history orders.- Returns:
- the history orders
-
getWorstDailyEquity
public it.unimi.dsi.fastutil.longs.Long2FloatRBTreeMap getWorstDailyEquity()Gets the worst daily equity.- Returns:
- the worst daily equity
-
getHistoryOrdersCount
public int getHistoryOrdersCount()Gets the history orders count.- Returns:
- the history orders count
-
getHistoryOrder
Gets the history order.- Parameters:
index
- the index- Returns:
- the history order
-
getAccountBalance
public double getAccountBalance()Gets the account balance.- Returns:
- the account balance
-
getAccountEquity
public double getAccountEquity()Gets the account equity.- Returns:
- the account equity
-
getInitialBalance
public double getInitialBalance()Gets the initial balance.- Returns:
- the initial balance
-
getStrategyName
Gets the strategy name.- Returns:
- the strategy name
-
getSetupName
Gets the setup name.- Returns:
- the setup name
-
setSettings
Sets the settings.- Parameters:
settings
- the new settings
-
getMoneyManagementMethod
Gets the money management method.- Returns:
- the money management method
-
getOpenOrdersCount
public int getOpenOrdersCount(boolean includeClosingOrders)Gets the open orders count.- Parameters:
includeClosingOrders
-- Returns:
- the open orders count
-
getOpenOrder
Gets the open order.- Parameters:
index
- the index- Returns:
- the open order
-
destroy
public void destroy()Destroy. -
fillAtRealAskBidPrice
public boolean fillAtRealAskBidPrice()Fill at real ask bid price.- Returns:
- true, if successful
-
getAmbiguousTrades
public int getAmbiguousTrades()Gets the ambiguous trades.- Returns:
- the ambiguous trades
-
evaluateActionListeners
public void evaluateActionListeners(int updateEventType, StrategyBase strategyBase) throws TradingExceptionEvaluate action listeners.- Parameters:
updateEventType
- the update event typestrategyBase
- the strategy base- Throws:
TradingException
- the trading exception
-
supportsDuplicateTrades
public boolean supportsDuplicateTrades()Supports duplicate trades.- Returns:
- true, if successful
-