Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 27th, 2012, 02:32 PM
vsatle vsatle is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 2 vsatle User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 54 m 2 sec
Reputation Power: 0
Help in writing a python script

Hi,

I am a beginner and work on various messages received from a company server related to different products and so on. I am looking for a python script that can sort messages with unique flag values and give me the output in a text file.

I get these messages in the form of .zcap file from server and I use an internal tool to filter:
Step 1) Zcap file to get security types,
Step 2) then filter each security types file that generate various exchanges files
Steps 3) lastly filter each exchange files to get message types files.

For eg: I filtered a .zcap file to get message types as –
BOND-----CVE----- MTR_BOND, MTFD_BOND, MTQ_BQUOTE, MTQ_MBBOQUOTE
BOND-----NYSE---- MTR_BOND, MTFD_BOND, MTQ_BQUOTE
BOND-----TSE--- MTR_BOND, MTFD_BOND, MTA_RECAP, MTT_TRADE, MTT_STATUS, MTA_CLOSE

Step 4) at present, I run a UNIX command on each message type (for eg; MTR_BOND) that generates multiple text files of each unique flag value messages .
$ awk '/MTQ/,/Quote Condition/{a[i++]=$0;if($0~/Flags:/){sub(":","",$2);fname=$2}if($0~/Quote Condition/){for(j=0;j<=i;j++)print a[j] > fname;i=0}}' MTA.txt

This is a very tedious job to run this command on each message type file (for eg; MTR_BOND) level, therefore I want a python script that I can run at Security Type level (for eg; BOND).
Can you please help me to write a python script (preferably) that I can run for each security type that will generate one output text file for each message types under each exchange with only 1 message of unique flag value.

I am unable to attach sample text files to this thread so, I’ve put some sample messages below:

MTQ_BQUOTE, Length: 49, Timestamp: 7:36:33.000
MsgKey: symbol: xxxx
Symbol: xxxx, hash 64555104
QS Symbol: xxx.xxx, market 28
Security Type: BOND (5)
Symbol Type: Bond.Share.Single.None
Session: CA_Day (4)
Ticker Exchange: TSE (16) => 16
Flags: x00000000
Bid: 9750, frac: 2, pure7 val: 0000
Bid Size: 6
Ask: 9995, frac: 2, pure7 val: 0000
Ask Size: 50
Quote Condition: x00

MTA_RECAP, Length: 76, Timestamp: 7:30:02.000
MsgKey: symbol: xxxx
Symbol: xxxx, hash 6454414F
QS Symbol: cNAT.DB, market 28
Security Type: BOND (5)
Symbol Type: Bond.Share.Single.None
Session: CA_Day (4)
Ticker Exchange: CVE (18) => 18
Flags: x00000000
Open: 0, frac: 3, pure7 val: ---
High: 0, frac: 3, pure7 val: ---
Low: 0, frac: 3, pure7 val: ---
Last: 0, frac: 3, pure7 val: ---
Last Market: 18
Change: 0, frac: 2, pure7 val: ---
Total Volume: 0
Bid: 9500, frac: 2, pure7 val: 00
Bid Market: 18
Ask: 9680, frac: 2, pure7 val: 00
Ask Market: 18
Bidtick Flag: x00000000

MTA_CLOSE, Length: 58, Timestamp: 16:05:12.234
MsgKey: symbol: xxxx
Symbol: xxxxx, hash 2F00717B
QS Symbol: xxxxx, market 12
Security Type: BOND (5)
Symbol Type: Bond.Share.Single.None
Session: US_Day (3)
Ticker Exchange: NYSE (7) => 7
Flags: x00000000:
Date: 10/5/2012
Open: 11425, frac: 2, pure7 val: 000
High: 11425, frac: 2, pure7 val: 000
Low: 11425, frac: 2, pure7 val: 000
Close: 11425, frac: 2, pure7 val: 0000
Total Volume: 10

Reply With Quote
  #2  
Old November 28th, 2012, 04:01 PM
b49P23TIvg's Avatar
b49P23TIvg b49P23TIvg is offline
Contributing User
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Aug 2011
Posts: 3,384 b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 3 Days 13 h 48 m 49 sec
Reputation Power: 383
I suppose you deserve a thoughtful answer but you're employed, and I'm not, and I have no clue what is a zcap file.
__________________
[code]Code tags[/code] are essential for python code!

Reply With Quote
  #3  
Old November 28th, 2012, 04:14 PM
vsatle vsatle is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 2 vsatle User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 54 m 2 sec
Reputation Power: 0
Smile

Quote:
Originally Posted by b49P23TIvg
I suppose you deserve a thoughtful answer but you're employed, and I'm not, and I have no clue what is a zcap file.


Thanks for your response. zcap is nothing but text files (sorry to mention company term). Please let me know if you have trouble understanding anything else in the post.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > Help in writing a python script

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap