FwdRatesDB

package 
{
	import valueObjects.FXRateDisplay;
	import valueObjects.TenorPointDisplay;
	import valueObjects.marketdata.FxForwardDisplay;
	
	import mx.collections.ArrayCollection;

	public class FwdRatesDB
	{
		
		private static var tenorsPointList:ArrayCollection = new ArrayCollection();
		tenorsPointList.addItem(buildTenorPointPair("O/N",0.245));
		tenorsPointList.addItem(buildTenorPointPair("1W",0.243));
		tenorsPointList.addItem(buildTenorPointPair("1M",0.241));
		tenorsPointList.addItem(buildTenorPointPair("3M",0.239));
		tenorsPointList.addItem(buildTenorPointPair("6M",0.235));
		tenorsPointList.addItem(buildTenorPointPair("12M",0.221));
		

		[Inject]
		public var ratesDB:RatesDB;
		[Bindable]
		public var fwdRates:ArrayCollection = new ArrayCollection();//of FXFwdRateDisplay
		
		private var started:Boolean = false;
		
		public function FwdRatesDB()
		{							
		}

		public function getFwdRates() : ArrayCollection
		{
			init();
			return fwdRates;
		}
		
		//This is purposely not using the [Init] tag, so we can run up the configMock
		//as a test, without it firing off dispatch messages due to this starting up during  
		//FlexBuilder
		private function init() : void
		{
			if(!started) {
				var allSpotRates:ArrayCollection = ratesDB.getRates();
				for(var i:int=0; i<allSpotRates.length; i++)
					fwdRates.addItem(buildFXForward(allSpotRates[i]));
				
				started = true;
			}
		}
	
		private static function buildTenorPointPair(tenor:String,value:Number) : TenorPointDisplay
		{
			var tpp:TenorPointDisplay = new TenorPointDisplay();
			tpp.tenor = tenor;
			tpp.point = value;
			return tpp;
		}
		
		private function buildFXForward(fwd:FxForwardDisplay) : FxForwardDisplay
		{
			var r : FxForwardDisplay = new FxForwardDisplay();

			r.update(fwd);
			return r;
		}
		
	}
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s