Class Trader

java.lang.Object
com.strategyquant.tradinglib.Trader

public class Trader extends Object
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 Details

    • Trader

      public Trader(String name, com.strategyquant.tradinglib.execution.IExecutionEngine executionEngine)
      Instantiates a new trader.
      Parameters:
      name - the name
      executionEngine - the execution engine
  • Method Details

    • setStrategy

      public void setStrategy(StrategyBase strategy)
      Sets the strategy.
      Parameters:
      strategy - the new strategy
    • getStrategy

      public StrategyBase getStrategy()
      Gets the strategy.
      Returns:
      the strategy
    • getName

      public String 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

      public ILiveOrder Open(byte tradeType, String symbol) throws TradingException
      Open.
      Parameters:
      tradeType - the trade type
      symbol - the symbol
      Returns:
      the i live order
      Throws:
      TradingException - the trading exception
    • Open

      public ILiveOrder Open(byte tradeType, String symbol, double price) throws TradingException
      Open.
      Parameters:
      tradeType - the trade type
      symbol - the symbol
      price - the price
      Returns:
      the i live order
      Throws:
      TradingException - the trading exception
    • Buy

      public ILiveOrder Buy(String symbol) throws TradingException
      Buy.
      Parameters:
      symbol - the symbol
      Returns:
      the i live order
      Throws:
      TradingException - the trading exception
    • Sell

      public ILiveOrder Sell(String symbol) throws TradingException
      Sell.
      Parameters:
      symbol - the symbol
      Returns:
      the i live order
      Throws:
      TradingException - the trading exception
    • BuyLimit

      public ILiveOrder BuyLimit(String symbol, double price) throws TradingException
      Buy limit.
      Parameters:
      symbol - the symbol
      price - the price
      Returns:
      the i live order
      Throws:
      TradingException - the trading exception
    • SellLimit

      public ILiveOrder SellLimit(String symbol, double price) throws TradingException
      Sell limit.
      Parameters:
      symbol - the symbol
      price - the price
      Returns:
      the i live order
      Throws:
      TradingException - the trading exception
    • BuyStop

      public ILiveOrder BuyStop(String symbol, double price) throws TradingException
      Buy stop.
      Parameters:
      symbol - the symbol
      price - the price
      Returns:
      the i live order
      Throws:
      TradingException - the trading exception
    • SellStop

      public ILiveOrder SellStop(String symbol, double price) throws TradingException
      Sell stop.
      Parameters:
      symbol - the symbol
      price - the price
      Returns:
      the i live order
      Throws:
      TradingException - the trading exception
    • BuyStopLimit

      public ILiveOrder BuyStopLimit(String symbol, double price) throws TradingException
      Buy stop limit.
      Parameters:
      symbol - the symbol
      price - the price
      Returns:
      the i live order
      Throws:
      TradingException - the trading exception
    • SellStopLimit

      public ILiveOrder SellStopLimit(String symbol, double price) throws TradingException
      Sell stop limit.
      Parameters:
      symbol - the symbol
      price - 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 TradingException
      Send.
      Parameters:
      order - the order
      action - the action
      syncType - the sync type
      orderEventListener - 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 TradingException
      Send.
      Parameters:
      order - the order
      action - the action
      additionalFlag - the additional flag
      syncType - the sync type
      orderEventListener - the order event listener
      Returns:
      the i live order
      Throws:
      TradingException - the trading exception
    • refuseOrder

      public ILiveOrder refuseOrder(ILiveOrder order, String message)
      Refuse order.
      Parameters:
      order - the order
      message - the message
      Returns:
      the i live order
    • getHistoryOrders

      public OrdersList 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

      public Order getHistoryOrder(int index)
      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

      public String getStrategyName()
      Gets the strategy name.
      Returns:
      the strategy name
    • getSetupName

      public String getSetupName()
      Gets the setup name.
      Returns:
      the setup name
    • setSettings

      public void setSettings(SettingsMap settings)
      Sets the settings.
      Parameters:
      settings - the new settings
    • getMoneyManagementMethod

      public MoneyManagementMethod 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

      public ILiveOrder getOpenOrder(int index, boolean includeClosingOrders)
      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 TradingException
      Evaluate action listeners.
      Parameters:
      updateEventType - the update event type
      strategyBase - the strategy base
      Throws:
      TradingException - the trading exception
    • supportsDuplicateTrades

      public boolean supportsDuplicateTrades()
      Supports duplicate trades.
      Returns:
      true, if successful