-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathgenerate_pair_list_config.py
More file actions
69 lines (53 loc) · 2.01 KB
/
generate_pair_list_config.py
File metadata and controls
69 lines (53 loc) · 2.01 KB
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
import json
import os
def make_noise():
# This is a placeholder for making noise; you can customize it as needed
print('\a') # This makes a beep noise in many systems
def fix_pairs(pairs):
corrected_pairs = []
changes_made = False
for pair in pairs:
base, suffix = pair.rsplit('/', 1)
if suffix != "USD":
corrected_pair = base + "/USD" # Correct the pair ending
corrected_pairs.append(corrected_pair)
print(f"Corrected pair: {pair} -> {corrected_pair}")
changes_made = True
else:
corrected_pairs.append(pair)
return corrected_pairs, changes_made
if __name__ == "__main__":
# Define the path to your pair list and the output config file
pair_list_path = 'pair_list.txt'
output_config_path = 'PAIR_LIST.json'
# Read the pair list from the text file
with open(pair_list_path, 'r') as file:
pairs = [line.strip() for line in file.readlines() if line.strip()]
# Remove duplicates
pairs = list(set(pairs))
# Fix any pairs with incorrect endings
pairs, changes_made = fix_pairs(pairs)
# Remove duplicates again after corrections
pairs = list(set(pairs))
# Make noise if any changes were made
if changes_made:
make_noise()
print("Incorrect pair endings found and corrected. See log for details.")
# Ensure BTC/USD is always included in the whitelist
default_pair = "BTC/USD"
if default_pair not in pairs:
pairs.append(default_pair)
# Print out the pair list
print(f"Pair list: {pairs}")
# Define the base structure of your configuration file
config = {
"exchange": {
"name": "kraken",
"pair_whitelist": pairs, # Insert the pair list here
"pair_blacklist": []
}
}
# Save the configuration to the JSON file
with open(output_config_path, 'w') as json_file:
json.dump(config, json_file, indent=4)
print(f"Config file generated at: {output_config_path}")