VeighNa量化社区
你的开源社区量化交易平台 | vn.py | vnpy
Member
avatar
加入于:
帖子: 422
声望: 188

很久没有升级了,今天升级了。发现很多新的东西,不知道有什么有,问问官方QuoteRequest有什么用?

  • list text here在vnpy>trader>object.py中增加了下面的代码:
[@dataclass](/user/dataclass)
class QuoteRequest:
    """
    Request sending to specific gateway for creating a new quote.
    """

    symbol: str
    exchange: Exchange
    bid_price: float
    bid_volume: int
    ask_price: float
    ask_volume: int
    bid_offset: Offset = Offset.NONE
    ask_offset: Offset = Offset.NONE
    reference: str = ""

    def __post_init__(self):
        """"""
        self.vt_symbol = f"{self.symbol}.{self.exchange.value}"

    def create_quote_data(self, quoteid: str, gateway_name: str) -> QuoteData:
        """
        Create quote data from request.
        """
        quote = QuoteData(
            symbol=self.symbol,
            exchange=self.exchange,
            quoteid=self.quoteid,
            bid_price=self.bid_price,
            bid_volume=self.bid_volume,
            ask_price=self.ask_price,
            ask_volume=self.ask_volume,
            bid_offset=self.bid_offset,
            ask_offset=self.ask_offset,
            reference=self.reference,
            gateway_name=gateway_name,
        )
        return quote
  • 在vnpy>trader>gateway.py中的BaseGateway类型总增加了下面的函数:
    def send_quote(self, req: QuoteRequest) -> str:
        """
        Send a new two-sided quote to server.

        implementation should finish the tasks blow:
        * create an QuoteData from req using QuoteRequest.create_quote_data
        * assign a unique(gateway instance scope) id to QuoteData.quoteid
        * send request to server
            * if request is sent, QuoteData.status should be set to Status.SUBMITTING
            * if request is failed to sent, QuoteData.status should be set to Status.REJECTED
        * response on_quote:
        * return vt_quoteid

        :return str vt_quoteid for created QuoteData
        """
        return ""   # 返回了空字符串,

返回了空字符串,其实什么用也没有,一个接口类函数。貌似是让其他的派生的特定网关来实现这个函数。
可是我查询了下,CTP、XTP等网关,没有一个实现了该函数,系统中也没有任何一个地方直接或者间接低调用过该send_quote()函数。

  • 从注释来看,好像是用来产生一个引用的作用?请问vnpy官方:这个东西有用吗?

编程是必须,交易理论才是根本。

Administrator
avatar
加入于:
帖子: 4452
声望: 343

这是给各种机构做市商双边报价用的,vn.py作为一套标准的底层框架,不是只有开源的功能嘛

Member
avatar
加入于:
帖子: 422
声望: 188

用Python的交易员 wrote:

这是给各种机构做市商双边报价用的,vn.py作为一套标准的底层框架,不是只有开源的功能嘛

谢谢答复!


编程是必须,交易理论才是根本。