`
guibin
  • 浏览: 366602 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

AioTrade Investigation (Section E: The logic of TickerServer)

阅读更多
AioTrade Investigation (Section E: The logic of TickerServer)
guibin.beijing@gmail.com
AioTrade source code: https://github.com/dcaoyuan/aiotrade

The TickerServer(org.aiotrade.lib.securities.dataserver.TickerServer) is a kind of DataServer which is used to process tickers. Tickers can be from the DBF, streaming, http request and so on. The TickerServer processes the incoming tickers, parses them, and then updates the internal Ser(Such as QuoteSer, MoneyFlowSer and so on) which is save in Sec. While processing the tickers, the TickerServer can also publish the relavent event to anyone who is interested in. The main logic of Ticker is almost in the method processData(values: Array[Ticker], Contract: TickerContract), details are below:

A) In levelI, the input comes from the dbf's parsing result,  namely a batch of incoming tickers at a specific time.

B) When the TickerServer gets the tickers, firstly converts these tickers into SecSnaps and tickersLast.
B1) SecSnap represents a sec's snapshot, including the latest newTicker, lastTicker, dailyQuote, minutelyQuote, dailyMoneyFlow, minutelyMoneyFlow. These data can be set by Ticker via setByTicker(ticker) or individually set its setter method of var.
B2) tickerLast represents the latest tickers. Some data copyFrom the incoming ticker in order to avoid the unwanted modifying.

C) Then traverse all the secSnaps to compute the minQuote's open, high, low, close, volume, amount, also it computes the execution. If the incoming ticker's time is not larger than the last ticker's time, we deem the incoming ticker is invalid.
C1) While traversing and if the ticker is valid, collects all the tickers into allTickers, so as to publish TickersEvt(allTickers) finally by TickerServer.
C2) While traversing and if the ticker is valid, collects all the executions into allExecutions so as to insert into database finally.
C3) While traversing and if the ticker is valid, collects all the DepthSnaps into allDepthSnaps so as to publish DepthSnapsEvt(allDepthSnaps) finally by TickerServer.
C4) While traversing and if the ticker is valid, updates the daily quote by ticker, then sends the minutely and daily QuoteEvt to sec to update the chain time series. At the same time, collecting all the dailyQuote and minutelyQuote so as to publish QuotesEvt(allUpdatedDailyQuotes) and QuotesEvt(allUpdatedMinuteQuotes) by TikerServer.
C5) While traversing and if the ticker is valid, the sec could also publish single TickerEvt and single ExecutionEvt.
C6) While traversing and if the ticker is valid, update the exchangeToLastTime so as to try to tryClosing finally.

D) According to the TrandingStatus and tradingTimeInMinutes to try to do close.

0
1
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics