MCPcopy
hub / github.com/microsoft/qlib / code_to_fname

Function code_to_fname

qlib/utils/__init__.py:905–922  ·  view source on GitHub ↗

stock code to file name Parameters ---------- code: str

(code: str)

Source from the content-addressed store, hash-verified

903
904
905def code_to_fname(code: str):
906 """stock code to file name
907
908 Parameters
909 ----------
910 code: str
911 """
912 # NOTE: In windows, the following name is I/O device, and the file with the corresponding name cannot be created
913 # reference: https://superuser.com/questions/86999/why-cant-i-name-a-folder-or-file-con-in-windows
914 replace_names = ["CON", "PRN", "AUX", "NUL"]
915 replace_names += [f"COM{i}" for i in range(10)]
916 replace_names += [f"LPT{i}" for i in range(10)]
917
918 prefix = "_qlib_"
919 if str(code).upper() in replace_names:
920 code = prefix + str(code)
921
922 return code
923
924
925def fname_to_code(fname: str):

Callers 7

_dump_binMethod · 0.90
save_instrumentMethod · 0.90
normalize_symbolMethod · 0.90
normalize_symbolMethod · 0.90
normalize_symbolMethod · 0.90
featureMethod · 0.85
period_featureMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected