Oandapy:期望 属性 名称用双引号引起来

Oandapy: Expecting property name enclosed in double quotes

我正在尝试使用本教程中所述的算法交易:

https://www.oreilly.com/learning/algorithmic-trading-in-less-than-100-lines-of-python-code

class MomentumTrader(opy.Streamer):
    def __init__(self, momentum, *args, **kwargs): 
        opy.Streamer.__init__(self, *args, **kwargs) 
        self.ticks = 0  
        self.position = 0 
        self.df = pd.DataFrame()  
        self.momentum = momentum  
        self.units = 100000 
    def create_order(self, side, units): 
        order = oanda.create_order(config["oanda"]["account_id"], 
            instrument="EUR_USD", units=units, side=side,
            type="market") 
        print("\n", order)  
    def on_success(self, data):  
        self.ticks += 1 
        # print(self.ticks, end=", ")
        # appends the new tick data to the DataFrame object
        self.df = self.df.append(pd.DataFrame(data["tick"],
                                 index=[data["tick"]["time"]]))  
        # transforms the time information to a DatetimeIndex object
        self.df.index = pd.DatetimeIndex(self.df["time"])  
        # resamples the data set to a new, homogeneous interval
        dfr = self.df.resample("5s").last() 
        # calculates the log returns
        dfr["returns"] = np.log(dfr["ask"] / dfr["ask"].shift(1))  
        # derives the positioning according to the momentum strategy
        dfr["position"] = np.sign(dfr["returns"].rolling( 
                                      self.momentum).mean())  
        if dfr["position"].ix[-1] == 1:  
            # go long
            if self.position == 0: 
                self.create_order("buy", self.units) 
            elif self.position == -1:  
                self.create_order("buy", self.units * 2)  
            self.position = 1  
        elif dfr["position"].ix[-1] == -1:  
            # go short
            if self.position == 0:  
                self.create_order("sell", self.units)  
            elif self.position == 1: 
                self.create_order("sell", self.units * 2)
            self.position = -1
        if self.ticks == 250: 
            # close out the position
            if self.position == 1:  
                self.create_order("sell", self.units)  
            elif self.position == -1:  
                self.create_order("buy", self.units) 
            self.disconnect()  



mt = MomentumTrader(momentum=12, environment="practice",
                access_token=config["oanda"]["access_token"])

mt.rates(account_id=config["oanda"]["account_id"],
     instruments=["DE30_EUR"], 
     ignore_heartbeat=True)

我收到这个错误:

JSONDecodeError: Expecting property name enclosed in double quotes: line 1 column 2 (char 1)

我想我需要使用 oandapyv20,但没有任何备忘单可以指导我如何将这些简单的代码片段迁移到新的 api。

那么应该使用什么来代替 "mt.rates"?

参见:Python code issues with Oanda API Rest V20 - Unable to run automatic code, v1 is deprecated. You need v20 support: https://github.com/benjaminchodroff/oandamomentum/blob/master/oandamomentumv20.ipynb