[英]how to read the variable value in the statement in python
data = alice.get_instrument_by_symbol(Exchange, EMA)
in this command Exchange
and EMA
both are able to read the data from varialble. data = alice.get_instrument_by_symbol(Exchange, EMA)
在这个命令中Exchange
和EMA
都能够从变量中读取数据。
but in the below command data = alice.get_instrument_for_fno(symbol = 'BANKNIFTY', expiry_date=datetime.date(2020, 10, 29), is_fut=False, strike=23200, is_CE = True)
---- working但是在下面的命令中
data = alice.get_instrument_for_fno(symbol = 'BANKNIFTY', expiry_date=datetime.date(2020, 10, 29), is_fut=False, strike=23200, is_CE = True)
----工作
data = alice.get_instrument_for_fno(symbol = 'Exchange', expiry_date=datetime.date(2020, 10, 29), is_fut=False, strike=23200, is_CE = True)
---- not working ------ data = alice.get_instrument_for_fno(symbol = 'Exchange', expiry_date=datetime.date(2020, 10, 29), is_fut=False, strike=23200, is_CE = True)
---- 不工作------
if i try to pass the same variable(Excahnge) it is not recognizing it.如果我尝试传递相同的变量(Excahnge),它就无法识别它。
looks like i am making some format issue in the python.看起来我在 python 中遇到了一些格式问题。 requesting for the help.
请求帮助。
In the first example ( data = alice.get_instrument_by_symbol(Exchange, EMA)
), Exchange
and EMA
are variables.在第一个示例(
data = alice.get_instrument_by_symbol(Exchange, EMA)
)中, Exchange
和EMA
是变量。 The Python interpreter replaces them with their values at runtime (ie if Exchange = 'BANKNIFTY'
is somewhere previous, EXCHANGE
will be replaced with BANKNIFTY
). Python 解释器在运行时将它们替换为它们的值(即,如果
Exchange = 'BANKNIFTY'
位于之前的某个位置,则EXCHANGE
将替换为BANKNIFTY
)。
In the second example, the symbol
keyword argument is getting passed in as a "string literal", meaning you explicitly say 'BANKNIFTY'
.在第二个示例中,
symbol
关键字参数作为“字符串文字”传入,这意味着您明确说'BANKNIFTY'
。
In the third example, you want to still use the Exchange
variable (from the first example) as the symbol
keyword argument to get_instrument_for_fno
:在第三个示例中,您仍希望使用
Exchange
变量(来自第一个示例)作为get_instrument_for_fno
的symbol
关键字参数:
data = alice.get_instrument_for_fno(
symbol = Exchange, # Notice the lack of quotes
expiry_date = datetime.date(2020, 10, 29),
is_fut = False,
strike = 23200,
is_CE = True,
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.