diff --git a/vnpy/api/da/generator/da_future_struct.py b/vnpy/api/da/generator/da_future_struct.py index 5095bf52..239bde6f 100644 --- a/vnpy/api/da/generator/da_future_struct.py +++ b/vnpy/api/da/generator/da_future_struct.py @@ -730,4 +730,3 @@ CFutureRspStrategyDetailField = { "SafeDeep": "int", "MainRange": "int", } - diff --git a/vnpy/api/da/generator/da_market_struct.py b/vnpy/api/da/generator/da_market_struct.py index e44fb64e..63144a7d 100644 --- a/vnpy/api/da/generator/da_market_struct.py +++ b/vnpy/api/da/generator/da_market_struct.py @@ -117,4 +117,3 @@ CMarketRspTradeDateField = { "TradeDate": "string", "TradeProduct": "string", } - diff --git a/vnpy/api/da/generator/da_stock_struct.py b/vnpy/api/da/generator/da_stock_struct.py index 896e8e91..a491d3c0 100644 --- a/vnpy/api/da/generator/da_stock_struct.py +++ b/vnpy/api/da/generator/da_stock_struct.py @@ -607,4 +607,3 @@ CStockReqVerifyCodeField = { "VerifyCode": "string", "ErrorDescription": "string", } - diff --git a/vnpy/api/da/generator/generate_api_functions.py b/vnpy/api/da/generator/generate_api_functions.py index 008a1d90..20c40e25 100644 --- a/vnpy/api/da/generator/generate_api_functions.py +++ b/vnpy/api/da/generator/generate_api_functions.py @@ -53,7 +53,7 @@ class ApiGenerator: line = line.replace("\n", "") line = line.replace("\t", "") line = line.replace("{}", "") - + if "virtual void On" in line: self.process_callback(line) elif "virtual bool Req" in line: @@ -130,7 +130,8 @@ class ApiGenerator: line = self.lines[name] on_name = name.replace("On", "on") - f.write(line.replace("virtual void ", f"void {self.class_name}::") + "\n") + f.write(line.replace("virtual void ", + f"void {self.class_name}::") + "\n") f.write("{\n") f.write("\tgil_scoped_acquire acquire;\n") @@ -149,13 +150,15 @@ class ApiGenerator: f.write("\tdict error;\n") f.write("\tif (pRspInfo)\n") f.write("\t{\n") - + struct_fields = self.structs[type_] for struct_field, struct_type in struct_fields.items(): if struct_type == "string": - f.write(f"\t\terror[\"{struct_field}\"] = toUtf({field}->{struct_field});\n") + f.write( + f"\t\terror[\"{struct_field}\"] = toUtf({field}->{struct_field});\n") else: - f.write(f"\t\terror[\"{struct_field}\"] = {field}->{struct_field};\n") + f.write( + f"\t\terror[\"{struct_field}\"] = {field}->{struct_field};\n") f.write("\t}\n") else: @@ -164,13 +167,15 @@ class ApiGenerator: f.write("\tdict data;\n") f.write(f"\tif ({field})\n") f.write("\t{\n") - + struct_fields = self.structs[type_] for struct_field, struct_type in struct_fields.items(): if struct_type == "string": - f.write(f"\t\tdata[\"{struct_field}\"] = toUtf({field}->{struct_field});\n") + f.write( + f"\t\tdata[\"{struct_field}\"] = toUtf({field}->{struct_field});\n") else: - f.write(f"\t\tdata[\"{struct_field}\"] = {field}->{struct_field};\n") + f.write( + f"\t\tdata[\"{struct_field}\"] = {field}->{struct_field};\n") f.write("\t}\n") @@ -260,11 +265,14 @@ class ApiGenerator: if __name__ == "__main__": - market_generator = ApiGenerator("../include/da/DAMarketApi.h", "da", "market", "MarketApi") + market_generator = ApiGenerator( + "../include/da/DAMarketApi.h", "da", "market", "MarketApi") market_generator.run() - future_generator = ApiGenerator("../include/da/DAFutureApi.h", "da", "future", "FutureApi") + future_generator = ApiGenerator( + "../include/da/DAFutureApi.h", "da", "future", "FutureApi") future_generator.run() - stock_generator = ApiGenerator("../include/da/DAStockApi.h", "da", "stock", "StockApi") + stock_generator = ApiGenerator( + "../include/da/DAStockApi.h", "da", "stock", "StockApi") stock_generator.run() diff --git a/vnpy/api/da/generator/generate_data_type.py b/vnpy/api/da/generator/generate_data_type.py index f3b5d785..2d25a4b9 100644 --- a/vnpy/api/da/generator/generate_data_type.py +++ b/vnpy/api/da/generator/generate_data_type.py @@ -41,7 +41,7 @@ class DataTypeGenerator: self.process_define(line) elif line.startswith("typedef"): self.process_typedef(line) - + def process_define(self, line: str): """处理常量定义""" words = line.split(" ") @@ -62,7 +62,7 @@ class DataTypeGenerator: """处理类型定义""" words = line.split(" ") words = [word for word in words if word] - + name = words[2] typedef = TYPE_CPP2PY[words[1]] diff --git a/vnpy/api/da/generator/generate_struct.py b/vnpy/api/da/generator/generate_struct.py index dc2a79e0..19430e34 100644 --- a/vnpy/api/da/generator/generate_struct.py +++ b/vnpy/api/da/generator/generate_struct.py @@ -60,7 +60,7 @@ class StructGenerator: value = words[2] new_line = f"{value} = {name}\n\n" self.f_struct.write(new_line) - + def process_declare(self, line: str): """处理声明""" words = line.split(" ") @@ -91,11 +91,14 @@ class StructGenerator: if __name__ == "__main__": - generator_future = StructGenerator("../include/da/DAFutureStruct.h", "da", "future") + generator_future = StructGenerator( + "../include/da/DAFutureStruct.h", "da", "future") generator_future.run() - generator_stock = StructGenerator("../include/da/DAStockStruct.h", "da", "stock") + generator_stock = StructGenerator( + "../include/da/DAStockStruct.h", "da", "stock") generator_stock.run() - generator_market = StructGenerator("../include/da/DAMarketStruct.h", "da", "market") + generator_market = StructGenerator( + "../include/da/DAMarketStruct.h", "da", "market") generator_market.run() diff --git a/vnpy/api/xgj/generator/xgj_struct.py b/vnpy/api/xgj/generator/xgj_struct.py index c96b0e15..51b0dbd9 100644 --- a/vnpy/api/xgj/generator/xgj_struct.py +++ b/vnpy/api/xgj/generator/xgj_struct.py @@ -4909,4 +4909,3 @@ CThostFtdcDepartmentUserField = { CThostFtdcQueryFreqField = { "QueryFreq": "int", } - diff --git a/vnpy/gateway/da/da_gateway.py b/vnpy/gateway/da/da_gateway.py index af876e2e..365e6587 100644 --- a/vnpy/gateway/da/da_gateway.py +++ b/vnpy/gateway/da/da_gateway.py @@ -444,7 +444,7 @@ class DaFutureApi(FutureApi): symbol_name_map[contract.vt_symbol] = contract.name symbol_currency_map[contract.symbol] = data["CommodityFCurrencyNo"] - + self.gateway.on_contract(contract) if last: diff --git a/vnpy/gateway/okexs/okexs_gateway.py b/vnpy/gateway/okexs/okexs_gateway.py index e297c319..6d7ea760 100644 --- a/vnpy/gateway/okexs/okexs_gateway.py +++ b/vnpy/gateway/okexs/okexs_gateway.py @@ -359,7 +359,7 @@ class OkexsRestApi(RestClient): """""" for data in datas: holdings = data['holding'] - + for holding in holdings: symbol = holding["instrument_id"].upper() pos = _parse_position_holding(holding, symbol=symbol,