stock code to file name Parameters ---------- code: str
(code: str)
| 903 | |
| 904 | |
| 905 | def 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 | |
| 925 | def fname_to_code(fname: str): |
no outgoing calls
no test coverage detected