{"id":259,"date":"2014-09-17T05:44:42","date_gmt":"2014-09-17T10:44:42","guid":{"rendered":"http:\/\/www.amibroker.com\/kb\/?p=259"},"modified":"2014-12-04T04:58:16","modified_gmt":"2014-12-04T09:58:16","slug":"how-to-display-bond-and-bill-prices-in-fractions","status":"publish","type":"post","link":"https:\/\/www.amibroker.com\/wordpress\/kb\/2014\/09\/17\/how-to-display-bond-and-bill-prices-in-fractions\/","title":{"rendered":"How to display Bond and Bill prices in fractions"},"content":{"rendered":"

Treasury Bond and Bill futures are traded in fractions, not decimals. A typical bond quote may be 124’21 which means 124 and 21\/32nds, so one needs special method to display prices in non-decimal format.<\/p>

To achieve desired result we need to do two things.<\/p>

1. Switch Y axis grid to desired fraction format. To make a change, right click on the chart and select Parameters<\/strong>, then switch to Axes & Grid<\/strong> tab and change Grid Format<\/strong> as shown below:<\/p>

\"Parameter<\/p>

2. Create a price chart with custom title showing fractions instead of decimals. Go to Analysis->Formula Editor<\/strong>, enter the following formula and press Apply Indicator<\/strong> toolbar button.<\/p><\/span>function <\/span>NumToFrac<\/span>( <\/span>num <\/span>)
{
  return <\/span>StrFormat<\/span>(<\/span>"%.0f'%0.f"<\/span>, <\/span>floor<\/span>( <\/span>num <\/span>), <\/span>frac<\/span>( <\/span>num <\/span>) * <\/span>320 <\/span>);
}
<\/span>Plot<\/span>( <\/span>Close<\/span>, <\/span>"Close"<\/span>, <\/span>colorDefault<\/span>, <\/span>styleCandle<\/span>);
<\/span>Title <\/span>= <\/span>"{{NAME}} - {{INTERVAL}} {{DATE}} Close: " <\/span>+ <\/span>NumToFrac<\/span>( <\/span>Close <\/span>)<\/code>

The NumToFrac function formats decimal value into full points and 1\/320nds fraction of the full point.<\/p>","protected":false},"excerpt":{"rendered":"

Treasury Bond and Bill futures are traded in fractions, not decimals. A typical bond quote may be 124’21 which means 124 and 21\/32nds, so one needs special method to display prices in non-decimal format.To achieve desired result we need to do two things.1. Switch Y axis grid to desired fraction format. To make a change, […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[10],"tags":[53,55,24],"_links":{"self":[{"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/posts\/259"}],"collection":[{"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/comments?post=259"}],"version-history":[{"count":1,"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/posts\/259\/revisions"}],"predecessor-version":[{"id":811,"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/posts\/259\/revisions\/811"}],"wp:attachment":[{"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/media?parent=259"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/categories?post=259"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/tags?post=259"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}