Я пишу api, тут не могу понять в чем дело.. Что я не правильно сделал?
def generate_rec_structures(currency, exp, lang):
s_path = os.path.dirname(os.path.realpath(__file__))
file_path = s_path + '/data.pickle'
with open(file_path, 'rb') as f:
data = pickle.load(f)
board = data[currency]
df = pd.DataFrame(board)
df = df.loc[df['instrument_name'].apply(lambda x: len(x.split('-'))) == 4]
df['exp'] = df['instrument_name'].apply(lambda x: x.split('-')[1])
df_tmp = df.loc[df['exp'] == exp]
df_tmp['strike'] = df_tmp['instrument_name'].apply(lambda x: x.split('-')[2])
strike_list = df_tmp['strike'].unique()
strike_list = [int(i) for i in strike_list]
strike_list = sorted(strike_list)
price = df_tmp['estimated_delivery_price'].mean()
data = []
strike_0 = utils.find_nearest(strike_list, price * 1.02)
strike_1 = utils.find_nearest(strike_list, price * 1.15)
if strike_0 == strike_1:
ind = strike_list.index(strike_1) + 1
if ind != len(strike_list):
strike_1 = strike_list[ind]
strike_0_str = str(int(strike_0))
strike_1_str = str(int(strike_1))
diff_str = str(int(strike_1 - strike_0))
if lang = 'ru':
description = "Если цена {3} при погашении выше {0} USD и ниже {1} USD, то инвестор получает дополнительный доход 1:1 отражающий рост {3}. Если цена {3} при погашении ниже {0} USD, то опционная составляющая оказывается вне денег, что эквивалентно 0% дополнительного дохода. Если цена {3} при погашении выше {1} USD, то дополнительный доход ограничен на уровне {2} USD (что эквивалентно {1} USD – {0} USD)".format(strike_0_str, strike_1_str, diff_str, currency)
else:
description = "If the price of {3} at maturity is above {0} USD and below {1} USD, then the investor receives an additional 1:1 income reflecting the growth of {3}. If the {3} price at maturity is below {0} USD, then the option component is out of the money, which is equivalent to 0% additional income. If the price of {3} at maturity is higher than {1} USD, then the additional income is capped at {2} USD (which is equivalent to {1} USD - {0} USD)".format(strike_0_str, strike_1_str, diff_str, currency)
data.append({
"structure":[
{
"instrument name":None,
"type":"call",
"direction":1,
"strike":strike_0,
"amount":1
},
{
"instrument name":None,
"type":"call",
"direction":-1,
"strike":strike_1,
"amount":1
}
],
"description":description,
"title":"Call-spread"
})
Ошибка
Traceback (most recent call last):
File "C:\Users\Vladik\Desktop\calculator_api (v-1.3)\main.py", line 10, in <module>
import structs
File "C:\Users\Vladik\Desktop\calculator_api (v-1.3)\structs.py", line 170
if lang = 'ru':
^
SyntaxError: invalid syntax