FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
quickfix-cpp/spec/GeneratorPython.rb at master · brobits/quickfix-cpp · GitHub
brobits
quickfix-cpp
Repository navigation
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
quickfix-cpp
/
spec
/
GeneratorPython.rb
Copy path
More file actions
More file actions
Latest commit
History
History
History
166 lines (144 loc) · 3.95 KB
Breadcrumbs
quickfix-cpp
/
spec
/
GeneratorPython.rb
Copy path
File metadata and controls
166 lines (144 loc) · 3.95 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
class
GeneratorPython
def
initialize
(
type
,
major
,
minor
,
sp
,
verid
,
dir
)
@type
=
type
@major
=
major
@minor
=
minor
@beginstring
=
type
+
"."
+
major
+
"."
+
minor
if
@type
==
"FIX"
&&
major
>=
"5"
@beginstring
=
"FIXT.1.1"
end
@depth
=
0
;
@dir
=
dir
+
"/"
if
(
sp
!=
"0"
)
@f
=
createFile
(
"quick"
+
type
.
downcase
+
major
+
minor
+
"sp
#{
sp
}
"
+
".py"
)
else
@f
=
createFile
(
"quick"
+
type
.
downcase
+
major
+
minor
+
".py"
)
end
@verid
=
verid
@messageStarted
=
false
end
def
createFile
(
name
)
attr
=
File
::
CREAT
|
File
::
TRUNC
|
File
::
RDWR
return
File
.
new
(
@dir
+
name
,
attr
,
0644
)
end
def
tabs
count
=
0
result
=
""
while
(
count
!=
@depth
)
result
+=
"
\t
"
count
+=
1
end
return
result
end
def
front
@f
.
puts
"import quickfix as fix"
@f
.
puts
end
def
field
(
name
,
number
)
end
def
headerStart
end
def
headerEnd
end
def
trailerStart
end
def
trailerEnd
end
def
baseMessageStart
@f
.
puts
tabs
+
"class Message(fix.Message):"
@depth
+=
1
@f
.
puts
tabs
+
"def __init__(self):"
@depth
+=
1
@f
.
puts
tabs
+
"fix.Message.__init__(self)"
@f
.
puts
tabs
+
"self.getHeader().setField( fix.BeginString("
+
"
\"
"
+
@beginstring
+
"
\"
"
+
") )"
if
(
@verid
!=
"0"
)
@f
.
puts
tabs
+
"self.getHeader().setField( fix.ApplVerID("
+
"
\"
"
+
@verid
+
"
\"
"
+
") )"
end
@depth
-=
1
@depth
-=
1
end
def
baseMessageEnd
end
def
groupStart
(
name
,
number
,
delim
,
order
)
return
if
@messageStarted
==
false
@f
.
puts
@depth
+=
1
@f
.
puts
tabs
+
"class "
+
name
+
"(fix.Group):"
@depth
+=
1
@f
.
puts
tabs
+
"def __init__(self):"
@depth
+=
1
@f
.
puts
tabs
+
"order = fix.IntArray(
#{
order
.
size
+
1
}
)"
order
.
each_index
{
|
i
|
@f
.
puts
tabs
+
"order[
#{
i
}
] =
#{
order
[
i
]
}
"
}
@f
.
puts
tabs
+
"order[
#{
order
.
size
}
] = 0"
@f
.
puts
tabs
+
"fix.Group.__init__(self,
#{
number
}
,
#{
delim
}
, order)"
@depth
-=
1
@depth
-=
1
end
def
groupEnd
return
if
@messageStarted
==
false
@depth
-=
1
end
def
messageStart
(
name
,
msgtype
,
required
)
@messageStarted
=
true
;
@f
.
puts
@f
.
puts
tabs
+
"class "
+
name
+
"(Message):"
@depth
+=
1
@f
.
puts
tabs
+
"def __init__(self):"
@depth
+=
1
@f
.
puts
tabs
+
"Message.__init__(self)"
@f
.
puts
tabs
+
"self.getHeader().setField( fix.MsgType("
+
"
\"
"
+
msgtype
+
"
\"
) )"
@depth
-=
1
@depth
-=
1
end
def
messageEnd
@messageStarted
=
false
end
def
fieldsStart
@f
=
createFile
(
"quickfix_fields.py"
)
@f
.
puts
tabs
+
"import quickfix"
@f
.
puts
end
def
fieldType
(
name
,
type
)
return
"CheckSum"
if
name
==
"CheckSum"
return
"Char"
if
type
==
"CHAR"
return
"Double"
if
type
==
"PRICE"
return
"Int"
if
type
==
"INT"
return
"Double"
if
type
==
"AMT"
return
"Double"
if
type
==
"QTY"
return
"UtcTimeStamp"
if
type
==
"UTCTIMESTAMP"
return
"Bool"
if
type
==
"BOOLEAN"
return
"Double"
if
type
==
"FLOAT"
return
"Double"
if
type
==
"PRICEOFFSET"
return
"UtcDate"
if
type
==
"UTCDATE"
return
"UtcDate"
if
type
==
"UTCDATEONLY"
return
"UtcTimeOnly"
if
type
==
"UTCTIMEONLY"
return
"Int"
if
type
==
"NUMINGROUP"
return
"Double"
if
type
==
"PERCENTAGE"
return
"Int"
if
type
==
"SEQNUM"
return
"Int"
if
type
==
"LENGTH"
return
"String"
end
def
fields
(
name
,
number
,
type
,
values
)
@f
.
puts
tabs
+
"class
#{
name
}
(quickfix.
#{
fieldType
(
name
,
type
)
}
Field):"
@depth
+=
1
@f
.
puts
tabs
+
"def __init__(self, data = None):"
@depth
+=
1
@f
.
puts
tabs
+
"if data == None:"
@depth
+=
1
@f
.
puts
tabs
+
"quickfix.
#{
fieldType
(
name
,
type
)
}
Field.__init__(self,
#{
number
}
)"
@depth
-=
1
@f
.
puts
tabs
+
"else:"
@depth
+=
1
@f
.
puts
tabs
+
"quickfix.
#{
fieldType
(
name
,
type
)
}
Field.__init__(self,
#{
number
}
, data)"
@depth
-=
1
@depth
-=
1
@depth
-=
1
@f
.
puts
end
def
fieldsEnd
@f
.
close
end
def
back
@f
.
close
end
end
Back
|
FazBrowse Home
|
New Git URL