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

Re: [amibroker] Substuting ";" with "," in a TWS trade file



PureBytes Links

Trading Reference Links

hi herman,
 
this is the closest I get using AFL. It does not seem to be possible to read and write to the same file (correct me if I'm wrong). So you have to make a change to the line and write it to another file. Also I run this from a chart window ..... Seems to me an external tool would be easier so you can change a whole directory at once.,
 
rgds, Ed 
 
 
// open file
fh =
fopen(fileName, "r");
fh2 =
fopen(fileName2, "w"
);
 

if
(fh) {

   
while( !feof
(fh ))  {
   
   
// read the file line by line

   ss =
fgets(fh);

   
// string length

   sl =
StrLen(ss);
   
   
// storage array

   newString =
"";
            
      
for (i=0
; i<sl; i++) {
      
         
if (StrMid(ss,i,1) == ";"
) {
         
            newString = newString +
","

          
         }
else
{
         
            newString = newString +
StrMid(ss,i,1
);
         
         }
          
      
      }
      
      
// write newString to file

      
fputs
(newString,fh2);

   }
   
}

fclose
(fh);
fclose
(fh2);
----- Original Message -----
Sent: Friday, April 08, 2005 10:32 AM
Subject: RE: [amibroker] Substuting ";" with "," in a TWS trade file

Thanks everyone for the replies!
 
My mind wasn't to clear last night and I was looking for a quick and easy solution; yes I'll use the afl str functions. I'll also email to AB-sugggest that the delimiter be made optional in the StrExtract(), like StrExtract( list, item, Delimiter="," )
 
I have been using StaticVariables to plot real trades on my charts but I think reading the actual TWS tradelist and plotting those values will be better and easier.
 
best regards,
herman
-----Original Message-----
From: Michael.S.G. [mailto:OzFalconAB@xxxxxxxx]
Sent: Friday, April 08, 2005 1:56 AM
To: amibroker@xxxxxxxxxxxxxxx
Subject: Re: [amibroker] Substuting ";" with "," in a TWS trade file

Herman,
    How do you want to do it?

I have a JScript file that does just what you are after.

Or (Prefered method) do as Ara said. Use StrFind etc
to locate each sub section.

eg (not real code)
Line = Readline from file....
for I = 1 to StrLen(Line)
Loc = StrFind(Line); //Find 1st occurance left to right
Part(I) = StrLeft(Line,Loc); //Allocate x part.
RightNum = StrLen(Line) - Loc; //Calc remaining  str len.
Line = StrRight(RightNum);
Next I;

Or something like that  (Have to check the RightNum assignment - I think
it's not quite right*)
Anyway gota go - Just popped home for 5min and out again. ;-)

*Umm yeah - The for loop will continue after the string has been
dismembered. You'd have to fix that.

Atb
    Michael.

Herman van den Bergen wrote:

> would anyone have code or know how to substitute semi-colons in a file
> with commas?

> The TWS outputs trade records in semi-colon separated text file, like so:

> RIMM;SLD;50;72.56;13:32:59;20050407;ISLAND;U84507;;;534;
> RIMM;BOT;100;73.04;13:37:49;20050407;ISLAND;U84507;;;534;
> RIMM;SLD;50;73.44;13:41:56;20050407;ISLAND;U84507;;;534;
> RIMM;SLD;50;73.44;13:41:56;20050407;ISLAND;U84507;;;534;

> I want to read the files with afl which would be so much easier if the
> semi-colons were commas.

> many thanks for any help you can give!

> herman
>
>
> Please note that this group is for discussion between users only.
>
> To get support from AmiBroker please send an e-mail directly to
> SUPPORT {at} amibroker.com
>
> For other support material please check also:
> http://www.amibroker.com/support.html
>
>
>
>
> ------------------------------------------------------------------------
> *Yahoo! Groups Links*
>
>     * To visit your group on the web, go to:
>       http://groups.yahoo.com/group/amibroker/
>       
>     * To unsubscribe from this group, send an email to:
>       amibroker-unsubscribe@xxxxxxxxxxxxxxx
>       <mailto:amibroker-unsubscribe@xxxxxxxxxxxxxxx?subject=Unsubscribe>
>       
>     * Your use of Yahoo! Groups is subject to the Yahoo! Terms of
>       Service <http://docs.yahoo.com/info/terms/>.
>
>



Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com

For other support material please check also:
http://www.amibroker.com/support.html





Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com

For other support material please check also:
http://www.amibroker.com/support.html





Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com

For other support material please check also:
http://www.amibroker.com/support.html





Yahoo! Groups Links