Giter Site home page Giter Site logo

vnpy_femas's Introduction

VeighNa框架的飞马柜台交易接口

说明

基于FEMAS期货柜台1.0版本开发的交易接口。

安装

安装环境推荐基于3.3.0版本以上的【VeighNa Studio】。

直接使用pip命令:

pip install vnpy_femas

或者下载源代码后,解压后在cmd中运行:

pip install .

使用源代码安装时需要进行C++编译,因此在执行上述命令之前请确保已经安装了【Visual Studio(Windows)】或者【GCC(Linux)】编译器。

使用

以脚本方式启动(script/run.py):

from vnpy.event import EventEngine
from vnpy.trader.engine import MainEngine
from vnpy.trader.ui import MainWindow, create_qapp

from vnpy_femas import FemasGateway


def main():
    """主入口函数"""
    qapp = create_qapp()

    event_engine = EventEngine()
    main_engine = MainEngine(event_engine)
    main_engine.add_gateway(FemasGateway)
    
    main_window = MainWindow(main_engine, event_engine)
    main_window.showMaximized()

    qapp.exec()


if __name__ == "__main__":
    main()

vnpy_femas's People

Contributors

edanflame avatar noranhe avatar vnpy avatar youyuanrsq avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

vnpy_femas's Issues

遇到一个femas很奇怪的问题

使用no_ui,algo_trading脚本,如果连接ctp柜台,取持仓没问题,但连接femas柜台,取持仓就是空值,如果用pycharm在debug下,能取到持仓,在运行模式下取不到。使用sleep(20),也不行。

1。test1.py
.......
def run_child():
"""
Running in the child process.
"""
SETTINGS["log.file"] = True

event_engine = EventEngine()
main_engine = MainEngine(event_engine)
# main_engine.add_gateway(CtpGateway)
main_engine.add_gateway(FemasGateway)
algo_engine = main_engine.add_app(AlgoTradingApp)
main_engine.write_log("主引擎创建成功")

log_engine = main_engine.get_engine("log")
event_engine.register(EVENT_ALGO_LOG, log_engine.process_log_event)
main_engine.write_log("注册日志事件监听")

# main_engine.connect(setting, "CTP")
main_engine.connect(setting, "FEMAS")
# main_engine.write_log("连接CTP接口")
main_engine.write_log("连接FEMAS接口")
main_engine.write_log(f"用户名: {setting['用户名']}")

sleep(10)

algo_engine.init_engine()
main_engine.write_log("引擎初始化完成")

#algo_engine.init_all_strategies()
#algo_engine.load_algo_template()

# my algo trading
algo_engine.add_algo_template(CalLostAlgo)
sleep(5)   # Leave enough time to complete strategy initialization
main_engine.write_log("引擎加载成功")

#algo_engine.start_all_strategies()
algo_engine.start_algo(algo_setting)

while True:
    sleep(1)
    #main_engine.write_log("    子进程")

def run_parent():
"""
Running in the parent process.
"""
print("启动网络算法守护父进程")

if trading and child_process is None:
        print("启动子进程")
        child_process = multiprocessing.Process(target=run_child)
        child_process.start()
        print("子进程启动成功")

2.test2.py ----- my algo trading

def on_start(self):
print("开始")
# 从柜台ctp读取仓位
positions = self.algo_engine.main_engine.get_all_positions()
print("wait 2.......")
sleep(20)

    if positions is not None:
        print("get")
        print(positions)
    else:
        print("empty")

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.