Develop Your System

This section is to discuss the key components in Cyan Spring framework and how to develop your system based on those components

Strategy Framework

Cyan Spring ATS provides a strategy framework for Single-instrument Strategies and Multi-instrument Strategies. You may click on the links Single-instrument Strategies and Multi-instrument Strategies to understand what they are.

To implement your own strategy in Cyan Spring ATS, you should choose either SingleInstrumentStrategy or MultiInstrumentStrategy as your parent class. Due to OO inheritance, your class immediately can do all sorts of things that parent class can do and you may add your business logic by overriding certain parent class methods.

In this section, we are going to discuss some key features the strategy framework provides. If you think the information is too dry you may skip it and go tutorial section for some immediate action. You may also look into the sample project in the source distribution package for several examples of strategies.

Common Strateigy methods

Both SingleInstrumentStrategy and MultiInstrumentStrategy inherit from com.cyanspring.strategy.Strategy class. com.cyanspring.strategy.Strategy contains some methods are common to all strategies in Cyan Spring ATS:

void init()
This mehtod does the initialisation job when strategy is created, typically subscribes to the events that the strategy is interested in.
void uninit()
This mehtod does the clean-up job when a strategy is destroyed.
void start()
Put the strategy into running state
void pause()
Put the strategy into pause state, leave child orders in market.
void stop()
Put the strategy into stop state, cancel all child orders in market.
void terminate()
Put the strategy into canceled state and remove it from strategy container.
void execute(ExecuteTiming timing)
This method is the strategy logic entry point, it will call your business logic in your derived class.
Collection getChildOrders()
Return all open(not cancelled or traded) child orders sent by this strategy
List getOpenChildOrdersByParent(String parent)
return a list of open child orders sent by a particular parent
Set getSortedOpenChildOrdersByParent(String parent)
return a list of open child orders in price/time order belongs to a particular parent
Set getSortedOpenChildOrdersBySymbol(String symbol)
return a list of open child orders in price/time order with same symbol
ChildOrder getChildOrder(String id)
return a child order with particular child order id
ChildOrder removeChildOrder(String id)
remove a child order with particular id
ChildOrder addChildOrder(ChildOrder order)
add a child order to strategy
int childOrderCount()
return the cound of all child orders