public string SpreadContractBbgTicker(BbgSpreadTickerFormation formation_) { switch (formation_) { case BbgSpreadTickerFormation.BaseYearBaseYear: return string.Format("{0}{1}{0}{2} {3}", BbgBase, ContractFront, ContractBack, BbgSuffix); case BbgSpreadTickerFormation.BaseYearYear: return string.Format("{0}{1}{2} {3}", BbgBase, ContractFront, ContractBack, BbgSuffix); case BbgSpreadTickerFormation.RBaseYearYear: return string.Format("R{0}{1}{2} {3}", BbgBase, ContractFront, ContractBack, BbgSuffix); case BbgSpreadTickerFormation.BaseDashYearBaseDashYear: return string.Format("{0}-{1}{0}-{2} {3}", BbgBase.Trim(), ContractFront, ContractBack, BbgSuffix); default: throw new Exception(string.Format("Need to implement spreadTickerFormation [{0}]", formation_)); } }
private void subscribeToBbgLive() { var gmtStartTime = TimeZoneHelper.ConvertDateTime(DateTime.Now.AddMinutes(-1d).StartOfMinute(), TimeZoneInfo.Local, TimeZoneInfo.Utc); // need to subscribe to 3 things, the priorContract, the newContract, and the spread m_spreadTickerFormation = AttributeHelper.GetSingleAttribute<BbgContractAttribute>(Set).SpreadTickerFormation; // 1) back contract { var ticker = BackContractBloombergTicker(); m_bbgLive_candles_BackContract = BbgTalk.Core.Instance.GetLiveSecurityBarData( gmtStartTime_: gmtStartTime, ticker_: ticker, barWidthInMinutes_: 1); m_bbgLive_Price_BackContract = BbgTalk.Core.Instance.GetLiveSecurity(securityId_: ticker, fields_: new[] { BBG_LIVE_FIELD }, intervalInSeconds_: 2d); subscribeToBackContractCandles(); } // 2) front contract { var ticker = FrontContractBloombergTicker(); m_bbgLive_candles_FrontContract = BbgTalk.Core.Instance.GetLiveSecurityBarData( gmtStartTime_: gmtStartTime, ticker_: ticker, barWidthInMinutes_: 1); m_bbgLive_Price_FrontContract = BbgTalk.Core.Instance.GetLiveSecurity(securityId_: ticker, fields_: new[] { BBG_LIVE_FIELD }, intervalInSeconds_: 2d); subscribeToFrontContractCandles(); subscribeToFrontContractPrice(); } // 3) spread { var ticker = SpreadContractBbgTicker(m_spreadTickerFormation); m_bbgLive_candles_spread = BbgTalk.Core.Instance.GetLiveSecurityBarData( gmtStartTime_: gmtStartTime, ticker_: ticker, barWidthInMinutes_: 1); m_bbgLive_Price_Spread = BbgTalk.Core.Instance.GetLiveSecurity(securityId_: ticker, fields_: new[] { BBG_LIVE_FIELD }, intervalInSeconds_: 2d); } subscribeToSpreadContractCandles(); subscribeToSpreadContractPrice(); }
public BbgContractAttribute(string bbgBase_, string bbgSuffix_, BbgSpreadTickerFormation spreadFormation_) { BbgBase = bbgBase_; BbgSuffix = bbgSuffix_; SpreadTickerFormation = spreadFormation_; }