查找点值 - 3 至 5 位数字的外汇定价计算
Find Pips value - 3 to 5 Digits forex pricing calculation
Nb in Python 问!尝试用 price.1(平仓交易)减去 price(开仓交易)以获得格式正确且不带小数点的点数。但是,由于涉及 split x lists.The 的限制,我无法继续进行,我正在尝试以下解决方案:,但是,似乎是冗余的..
我已经创建了 4 个列表和 4 个循环来将浮点数转换为字符串,更改格式以继续减法。知道如何格式化正确的数字吗?直接进入列(结果)的东西 float .. 如果标点符号 decimal 之前有 3 位数字。 .做 1000*100.. 如果一位数字在 . .. * 100/10。
# Price Trade Opened
listp = []
listpf = []
for i in df2['Price']:
listp.append(format(i,'.5f'))
for i in listp:
listpf.append(str(i))
# Price.1 trade closed.
listpp = []
listppf = []
for i in df2['Price.1']:
listpp.append(format(i,'.5f'))
for i in listpp:
listppf.append(str(i))
# Transform list into DF and remove punctuation. Thereby, I could
subtract.
df3 = pd.DataFrame(listp)
col = ['Price']
df3.columns = col
df3 = df3.stack().str.replace('.', '').unstack()
df4 = pd.DataFrame(listpp)
col = ['Price1']
df4.columns = col
df4 = df4.stack().str.replace('.', '').unstack()
dfc = pd.concat([df3, df4], axis=1)
dfc.fillna(0)
dfc.replace({'nan': 0}, inplace=True)
dfc['Price'] = pd.to_numeric(dfc['Price'])
dfc['Price1'] = pd.to_numeric(dfc['Price1'])
dfc['Result'] = (dfc['Price'] - dfc['Price1'])
dfc.head()
您应该能够计算开盘价和收盘价之间的差值,并除以该货币对的相关乘数。像这样:
def pip_calc(open, close):
if str(open).index('.') >= 3: # JPY pair
multiplier = 0.01
else:
multiplier = 0.0001
pips = round((close - open) / multiplier)
return int(pips)
pip_calc(112.65, 112.68)
# 3
pip_calc(1.6566, 1.6568)
# 2
Nb in Python 问!尝试用 price.1(平仓交易)减去 price(开仓交易)以获得格式正确且不带小数点的点数。但是,由于涉及 split x lists.The 的限制,我无法继续进行,我正在尝试以下解决方案:,但是,似乎是冗余的.. 我已经创建了 4 个列表和 4 个循环来将浮点数转换为字符串,更改格式以继续减法。知道如何格式化正确的数字吗?直接进入列(结果)的东西 float .. 如果标点符号 decimal 之前有 3 位数字。 .做 1000*100.. 如果一位数字在 . .. * 100/10。
# Price Trade Opened
listp = []
listpf = []
for i in df2['Price']:
listp.append(format(i,'.5f'))
for i in listp:
listpf.append(str(i))
# Price.1 trade closed.
listpp = []
listppf = []
for i in df2['Price.1']:
listpp.append(format(i,'.5f'))
for i in listpp:
listppf.append(str(i))
# Transform list into DF and remove punctuation. Thereby, I could
subtract.
df3 = pd.DataFrame(listp)
col = ['Price']
df3.columns = col
df3 = df3.stack().str.replace('.', '').unstack()
df4 = pd.DataFrame(listpp)
col = ['Price1']
df4.columns = col
df4 = df4.stack().str.replace('.', '').unstack()
dfc = pd.concat([df3, df4], axis=1)
dfc.fillna(0)
dfc.replace({'nan': 0}, inplace=True)
dfc['Price'] = pd.to_numeric(dfc['Price'])
dfc['Price1'] = pd.to_numeric(dfc['Price1'])
dfc['Result'] = (dfc['Price'] - dfc['Price1'])
dfc.head()
您应该能够计算开盘价和收盘价之间的差值,并除以该货币对的相关乘数。像这样:
def pip_calc(open, close):
if str(open).index('.') >= 3: # JPY pair
multiplier = 0.01
else:
multiplier = 0.0001
pips = round((close - open) / multiplier)
return int(pips)
pip_calc(112.65, 112.68)
# 3
pip_calc(1.6566, 1.6568)
# 2