[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Excel decimal to bond tick question



PureBytes Links

Trading Reference Links

Peter,

For what it's worth here's a VBA macro I use convert to 32nds.  It can be
easily adjusted to 64ths.  I'm trying to think if there's a way to apply
this function quickly to a large set of data.  I can't think of one right
now but maybe someone else can or it will come to me later.  Actually, you
could write a quick VBA app to take the contents of the cell with the
imported value from Tradestation, put that number in a function call to this
routine, then go back to your spreadsheet and press F9 to calculate all the
cells.  Make sure you have the radio button Manual selected (Options >
Calculation Tab > Manual) before writing this otherwise Excell may appear to
hang.  I use this routine to take the decimal output from Tradestation
written to an ASCII file, convert to ticks before writing to a cell on my
spreadsheet.  This is a realtively easy function to implment and a good way
to learn how VBA works.

Ex:
CELL A1=128.312
CONVERT WITH VBA APP TO: =NumConvert(128.312)
PUT THIS BACK IN CELL

VBA Code:

'----------------------------
' INPUT:
'   tkr is the two character symbol of the market you wish to convert. Ex:
for bonds the tkr="US"
'   num = the number you wish to convert in decimal format.
'----------------------------

Function NumConvert (tkr as Variant, num as Variant) as Variant

	Dim t as integer
	Dim iNumA as integer
	Dim iCarry as integer

	If tkr = "US" or tkr = "MB" then

		t = Sgn(num) 'Save sign of number
		num = Abs(num) 'allows accurate subtraction
		iCarry = 0
		iNumA = Format((num - Int(num) * 32, "0"))
		If iNumA = 32 then
			iNUmA = 0
			iCarry = 0
		end if
		num = (Int(num) + iCarry) & "-" & iNumA
		if t = -1 then num = "-" & num
	end if

	numConvert = num

End Function

-----Original Message-----
From:	Peter Iovanella [mailto:ivo1@xxxxxxxxx]
Sent:	Monday, November 23, 1998 11:29 AM
To:	Peter Iovanella; Mark Brown; omega-list@xxxxxxxxxx
Subject:	Re: Excel decimal to bond tick question

Also, how might I get Excel to show the half ticks in the Five Year Notes,
other than making it "# ?/64" and multiplying in my mind?

Thanks again.

Peter

-----Original Message-----
From: Peter Iovanella <ivo1@xxxxxxxxx>
To: Mark Brown <markbrown@xxxxxxxxxxxxx>; omega-list@xxxxxxxxxx
<omega-list@xxxxxxxxxx>
Date: Monday, November 23, 1998 2:19 PM
Subject: Re: Excel decimal to bond tick question


>Thanks - do you know if there is any way to make it appear like 124^13
>rather than 124 13/32?  And I had to make a custom format, as Michael Joyce
>suggested, since there isn't an ??/32 one provided with Excel.
>
>Peter
>
>
>-----Original Message-----
>From: Mark Brown <markbrown@xxxxxxxxxxxxx>
>To: Peter Iovanella <ivo1@xxxxxxxxx>; omega-list@xxxxxxxxxx
><omega-list@xxxxxxxxxx>
>Date: Monday, November 23, 1998 1:59 PM
>Subject: Re: Excel decimal to bond tick question
>
>
>>
>>click on the cell then hit format then choose fraction pick what you want,
>>click ok...done...next?
>>
>>
>>>Format them how?  I mean, do I have to create my own custom format, or is
>>it
>>>included within Excel?
>>>
>>>
>>>-----Original Message-----
>>>From: Mark Brown <markbrown@xxxxxxxxxxxxx>
>>>To: Peter Iovanella <ivo1@xxxxxxxxx>; omega-list@xxxxxxxxxx
>>><omega-list@xxxxxxxxxx>
>>>Date: Monday, November 23, 1998 1:45 PM
>>>Subject: Re: Excel decimal to bond tick question
>>>
>>>
>>>>yes you can do it in excel , format the numbers dude!
>>>>
>>>>
>>>>
>>>>-----Original Message-----
>>>>From: Peter Iovanella <ivo1@xxxxxxxxx>
>>>>To: omega-list@xxxxxxxxxx <omega-list@xxxxxxxxxx>
>>>>Date: Monday, November 23, 1998 12:38 PM
>>>>Subject: Excel decimal to bond tick question
>>>>
>>>>
>>>>>Is there any macro out there that will allow me to see prices I import
>>>into
>>>>>Excel from TS in terms of ticks rather than in decimal form?  For
>>example,
>>>>>how I can get 113.75 to appear as 113^24.  I assume that TS has some
>>>>>built-in routine to do this; is there anything I can do in Excel to
>>>emulate
>>>>>this?  Thanks!
>>>>>
>>>>>BJ
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>