commodities convert dict key to value, vice versa
This commit is contained in:
parent
5296819e48
commit
016068e393
23
server.py
23
server.py
@ -173,8 +173,18 @@ def index():
|
||||
stocks_settings = json.load(f)
|
||||
f.close()
|
||||
|
||||
dict1 = {
|
||||
"Aluminum": "ALU", "Brent Crude Oil": "BRENTOIL", "Coffee": "COFFEE", "Copper": "XCU", "Corn": "CORN", "Cotton": "COTTON", "Gold": "XAU",
|
||||
"Palladium": "XPD", "Platinum": "XPT", "Rice": "RICE", "Silver": "XAG", "Soybean": "SOYBEAN", "Sugar": "SUGAR", "Wheat": "WHEAT",
|
||||
"WTI Crude Oil": "WTIOIL", "Ethanol": "ETHANOL", "Crude Palm Oil": "CPO", "Natural Gas": "NG", "Cocoa": "COCOA", "Robusta": "ROBUSTA",
|
||||
"Lumber": "LUMBER", "Rubber": "RUBBER", "Live Cattle": "CATTLE", "Lean Hog": "HOG"}
|
||||
f = open('csv/commodities_settings.json', 'r')
|
||||
commodities_settings = json.load(f)
|
||||
try:
|
||||
reversed_dict1 = {value: key for key, value in dict1.items()}
|
||||
commodities_settings['symbols'] = [reversed_dict1[value] for value in commodities_settings['symbols']]
|
||||
except:
|
||||
pass
|
||||
f.close()
|
||||
|
||||
f = open('csv/indices_settings.json', 'r')
|
||||
@ -999,6 +1009,12 @@ def combine_dict(current_settings, input_symbols, current_key):
|
||||
|
||||
def save_trade_settings(input_settings):
|
||||
|
||||
commodities_dict = {
|
||||
"Aluminum": "ALU", "Brent Crude Oil": "BRENTOIL", "Coffee": "COFFEE", "Copper": "XCU", "Corn": "CORN", "Cotton": "COTTON", "Gold": "XAU",
|
||||
"Palladium": "XPD", "Platinum": "XPT", "Rice": "RICE", "Silver": "XAG", "Soybean": "SOYBEAN", "Sugar": "SUGAR", "Wheat": "WHEAT",
|
||||
"WTI Crude Oil": "WTIOIL", "Ethanol": "ETHANOL", "Crude Palm Oil": "CPO", "Natural Gas": "NG", "Cocoa": "COCOA", "Robusta": "ROBUSTA",
|
||||
"Lumber": "LUMBER", "Rubber": "RUBBER", "Live Cattle": "CATTLE", "Lean Hog": "HOG"
|
||||
}
|
||||
|
||||
filename = input_settings['feature'].lower() + '_settings.json'
|
||||
f = open('csv/' + filename, 'r')
|
||||
@ -1016,7 +1032,12 @@ def save_trade_settings(input_settings):
|
||||
if input_settings['feature'] == 'Stocks':
|
||||
current_settings['prepost'] = input_settings['prepost']
|
||||
if input_settings['feature'] == 'Stocks' or input_settings['feature'] == 'Crypto':
|
||||
current_settings['chart'] = input_settings['chart']
|
||||
current_settings['chart'] = input_settings['chart']
|
||||
if input_settings['feature'] == 'Commodities':
|
||||
try:
|
||||
input_settings['symbols'] = [commodities_dict[symbol] for symbol in input_settings['symbols']]
|
||||
except:
|
||||
pass
|
||||
|
||||
current_settings = combine_dict(current_settings, input_settings['symbols'], 'symbols')
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user