Coder Social home page Coder Social logo

sfl_trader's Introduction

sfl_trader 一个简洁快速轻量级的可扩展的程序化交易框架

  • Linux,python3,目前的交易接口只有CTP
  • 采用了Quicklib的底层架构,感谢Quicklib作者wdgwz
  • pevents将Quicklib使用的Windows系统的WaitForMultipleObjects移植到Linux系统,感谢pevents的作者neosmartmqudsi

扩展

  事件机制类似于WaitForMultipleObjects。目前系统有4个事件,分别为CTP的tick数据,CTP的报单回报,定时任务,循环任务。
  如果想增加事件,首先修改base.cfg中的事件总数,然后在底层调用base.so的api_set函数抛事件,或者用api_base.py中APIBase对象的set方法抛事件。最后自定回调函数,处理事件的线程由my_main.py中的Kernel.api_base.start_wait(FUNC_MAP)启动。base.so的数据在同一个进程中是共用的(确保调用了相同目录下的base.so),在不同的进程间不共用。
  如果想增加交易API,建议在api目录下新建文件夹,调用api/base目录下的base.so将所有事件串联起来。

使用

  CTP行情和交易接口的配置文件分别是md.cfg和td.cfg。
  新建策略:在strategy目录下新建一个python文件,定义一个继承Kernel的策略对象,实现有关的回调函数。
  在my_main.py中实例化策略对象,调用start方法启动策略。
  一个例子见cta_demo.py,该例子的描述见doc目录下的cta_demo描述.docx和cta_demo状态机.pdf。
  登录CTP交易接口时会在当前目录形成一个all_instruments.csv文件,为市场全部合约代码。
  email_queue.py用于发送邮件通知。在策略自动运行于云服务器上,无人看守的情况下,适时发送策略运行情况是很有必要的。邮箱的配置信息在代码中。

作者联系方式

[email protected]

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.