MCPcopy Create free account
hub / github.com/TraderAlice/OpenAlice / make_field

Function make_field

packages/ibkr/ref/source/pythonclient/ibapi/comm.py:41–61  ·  view source on GitHub ↗

adds the NULL string terminator

(val)

Source from the content-addressed store, hash-verified

39
40
41def make_field(val) -> str:
42 """adds the NULL string terminator"""
43 if val is None:
44 raise ValueError("Cannot send None to TWS")
45
46 # if string is not empty and contains invalid symbols
47 if val is not None and type(val) == str and val and not isAsciiPrintable(val):
48 raise ClientException(
49 INVALID_SYMBOL.code(),
50 INVALID_SYMBOL.msg(),
51 val.encode(sys.stdout.encoding, errors="ignore").decode(
52 sys.stdout.encoding
53 ),
54 )
55
56 # bool type is encoded as int
57 if val is not None and type(val) == bool:
58 val = int(val)
59
60 field = str(val) + "\0"
61 return field
62
63
64def make_field_handle_empty(val) -> str:

Callers 15

startApiMethod · 0.90
reqCurrentTimeMethod · 0.90
setServerLogLevelMethod · 0.90
reqMktDataMethod · 0.90
cancelMktDataMethod · 0.90
reqMarketDataTypeMethod · 0.90
reqSmartComponentsMethod · 0.90
reqMarketRuleMethod · 0.90
reqTickByTickDataMethod · 0.90
cancelTickByTickDataMethod · 0.90

Calls 6

isAsciiPrintableFunction · 0.90
ClientExceptionClass · 0.90
decodeMethod · 0.65
encodeMethod · 0.65
codeMethod · 0.45
msgMethod · 0.45

Tested by

no test coverage detected