Coder Social home page Coder Social logo

Comments (4)

Zhaoyvke avatar Zhaoyvke commented on August 21, 2024 2

已协助一村解决。通过parserUDP转发时候可用testudp查看是否正确转发行情,目测已转发出。需要在run中改主kline合约代码。检查订阅的合约是否有行情。
b5f37ebaeb544ddf51b5b9c7c878d20

ac857aa46918918c9dad5e0596f41ab

from wtpy.

linonetwo avatar linonetwo commented on August 21, 2024

是配置用法问题(但不确定是哪里配错了),因为 C++ 写的 parser 也收不到信息。但是 ParserCTP 用同样的接口在发消息就能收到。

ParserRandom 生成随机测试行情的代码

void ParserRandom::subscribe(const CodeSet &vecSymbols)
{
	m_running = true;
	std::thread(&ParserRandom::generateRandomData, this, vecSymbols).detach();
}

void ParserRandom::unsubscribe(const CodeSet &vecSymbols)
{
	m_running = false;
}

void ParserRandom::generateRandomData(const CodeSet &vecSymbols)
{
	std::default_random_engine generator(static_cast<long unsigned int>(time(0)));
	std::uniform_real_distribution<double> priceDist(100.0, 200.0); // Example price range
	std::uniform_int_distribution<int> volumeDist(100, 1000);				// Example volume range

	while (m_running)
	{
		for (const std::string &symbol : vecSymbols)
		{
			WTSTickData *tick = WTSTickData::create("IC2401");
			WTSTickStruct &quote = tick->getTickStruct();
			// strcpy(quote.exchg, pCommInfo->getExchg());
			strcpy(quote.exchg, "CFFEX");
			m_uTradingDate = TimeUtils::getCurDate();

			// Randomly generate the fields similar to OnRtnDepthMarketData
			quote.price = priceDist(generator);
			quote.open = priceDist(generator);
			quote.high = priceDist(generator);
			quote.low = priceDist(generator);
			quote.total_volume = volumeDist(generator);
			quote.trading_date = m_uTradingDate;
			// ... fill other fields similarly

			// Print tick data for debugging
			// std::cout << "Symbol: " << symbol << ", Price: " << quote.price << ", Volume: " << quote.total_volume << std::endl;

			if (m_sink)
				m_sink->handleQuote(tick, 1);

			tick->release();
		}

		std::this_thread::sleep_for(std::chrono::seconds(1));
	}
}

可能是 session 等地方配错了。

mdparsers.yaml

parsers:    # 行情通道配置
-   active: true
    broker: '8888'
    code: ''  # 要录制的合约代码,如果为空默认contracts.json中的全部,不为空则只录制指定的合约,注意这里须与contracts中的代码一致!如'CFFEX.IF2408, CFFEX.IF2403'
    front: tcp://121.37.90.193:20004  #openctp
    id: parser
    user: 1234
    pass: 123456
    module: ParserRandom

dtcfg.yaml

basefiles:  # 基础文件
    commodity: ../common/commodities.json
    contract: ../common/contracts.json
    holiday: ../common/holidays.json
    session: ../common/sessions.json
    utf-8: true
broadcaster:                    # UDP广播器配置项,如果要在局域网转发行情,可以使用该模块
    active: true
    bport: 3997                 # UDP查询端口,主要是用于查询最新的快照
    broadcast:                  # 广播配置
    -   host: 255.255.255.255   # 广播地址,255.255.255.255会向整个局域网广播,但是受限于路由器
        port: 9001              # 广播端口,接收端口要和广播端口一致
        type: 2                 # 数据类型,固定为2
shmcaster:                      # 共享内存转发,适合本机转发
    active: true
    path: ./exchange.membin     # memmap文件路径
parsers: mdparsers.yaml
statemonitor: statemonitor.yaml
writer: # 数据落地配置
    module: WtDataStorage #数据存储模块
    async: true          #同步落地还是异步落地,期货推荐同步,股票推荐异步
    groupsize: 20         #日志分组大小,主要用于控制日志输出,当订阅合约较多时,推荐1000以上,当订阅的合约数较少时,推荐100以内
    path: ../storage_AD    #数据存储的路径
    savelog: true        #是否保存tick到csv
    disabletick: false    #不保存tick数据,默认false
    disablemin1: false    #不保存min1数据,默认false
    disablemin5: false    #不保存min5数据,默认false
    disableday: false     #不保存day数据,默认false
    disablehis: false     #收盘作业不转储历史数据,默认false

commodities.json

{
   "CFFEX": {
        "IC": {
            "covermode": 0,
            "pricemode": 0,
            "category": 1,
            "precision": 1,
            "pricetick": 0.2,
            "volscale": 200,
            "name": "中证",
            "exchg": "CFFEX",
            "session": "SD0930",
            "holiday": "CHINA"
        },

sessions.json

{
    "SD0930":{
        "name":"股票白盘0930",
        "offset": 0,
        "auction":{
            "from": 929,
            "to": 930
        },
        "sections":[
            {
                "from": 930,
                "to": 1130
            },
            {
                "from": 1300,
                "to": 1500
            }
        ]
    },
    "FD0915":{
        "name":"期货白盘0915",
        "offset": 0,
        "auction":{
            "from": 929,
            "to": 930
        },
        "sections":[
            {
                "from": 930,
                "to": 1130
            },
            {
                "from": 1300,
                "to": 1515
            }
        ]
    },

运行后没有接收到行情。(我在 c++ 部分加过 log,c++ 那边是一直在循环输出行情的)

img_v3_0265_9e4cb30b-bb0b-4aae-87c3-cc9152a059cg

而同时如果使用 ParserCTP 就能正常收到 tick

截屏2023-12-15 13 28 15

from wtpy.

linonetwo avatar linonetwo commented on August 21, 2024

感谢,我昨天写了个自动产 parser 的 CI,今天让他自己改改合约名多试试…

from wtpy.

wondertrader avatar wondertrader commented on August 21, 2024

推荐检查流程:
1、检查是否正确配置自定义品种的合约信息
2、使用testUDP检查是否正确转发
3、检查策略是否正确订阅tick数据

from wtpy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.