Skip to main content

inquant future quant api

Project description

inquant future quant api

-- coding: utf-8 --

from StrategyTemplate import *

class MyStrategy(StrategyTemplate): """我的策略"""

def __init__(self):
    """构造函数"""
    super(MyStrategy,self).__init__()

def OnTick(self, data):
    """Tick数据处理 注data参数一次只有一条tick数据"""
    print("tickqqqqq",data.Symbol,data.LocalTime,data.Exchange)

    pass

def OnBar(self, data):
    """Bar数据处理 注data参数一次只有一条bar数据"""
    print("bar",data.Symbol,data.LocalTime,data.Exchange)

    resp10 = strategy.GetLastBar('rb1901',Exchange.SHFE,60,5)

    print(resp10[0].Symbol,resp10[0].LocalTime)
    pass

def OnOrderChanged(self,order):
    """成交回报处理"""
    pass

def TaskCallback(self):
    print(datetime.now().time())

if name == 'main':

#新建策略
strategy = MyStrategy()

#创建定时任务
strategy.CreateScheduler(strategy.TaskCallback,[90000,161005])

contracts = strategy.GetFutContracts('rb',Exchange.SHFE,-1)
contracts = strategy.GetFutContracts('rb',Exchange.SHFE,0)
contracts = strategy.GetFutContracts('rb',Exchange.SHFE,1)
contracts = strategy.GetFutContracts('rb',Exchange.SHFE,2)
contracts = strategy.GetFutContracts('rb',Exchange.SHFE,3)

strategy.WriteInfo(u"开始初始化策略...")
#初始化
ret = strategy.Init("demo.json","d:\\strategylog\\")
if not ret:
    strategy.WriteError("u初始化策略失败!!!")
    input(u"按任意键退出")
    sys.exit()
strategy.WriteInfo(u"初始化策略成功")

strategy.WriteInfo(u"开始启动策略...")
resp = strategy.Start()
if not resp:
    strategy.WriteError(u"策略启动失败!!")
    input(u"按任意键退出")
    sys.exit()
strategy.WriteInfo(u"策略启动成功")

resp4 = strategy.SendOrder('rb1901',Exchange.SHFE,OrderSide.Buy,4166,1,OrderType.LMT,Offset.Open)
resp5 = strategy.CancelOrder('7ba0ab1c8319442299c835269f600f3f')

resp1 = strategy.GetAssetInfo()
resp2 = strategy.GetOrders()
resp3 = strategy.GetPositions()

resp6 = strategy.GetOrder('7ba0ab1c8319442299c835269f600f3f')
resp7 = strategy.GetOpenOrders()
resp8 = strategy.GetContract('rb1901',Exchange.SHFE)
resp9 = strategy.GetLastTick('rb1901',Exchange.SHFE,2)
resp10 = strategy.GetLastBar('rb1901',Exchange.SHFE,300,5)

input(u"策略执行中,按任意键退出...")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

inquant-1.1.8.tar.gz (252.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

inquant-1.1.8-py3-none-any.whl (258.2 kB view details)

Uploaded Python 3

File details

Details for the file inquant-1.1.8.tar.gz.

File metadata

  • Download URL: inquant-1.1.8.tar.gz
  • Upload date:
  • Size: 252.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.18.4 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.5

File hashes

Hashes for inquant-1.1.8.tar.gz
Algorithm Hash digest
SHA256 3974e6591c09b929ff63c3d02136e3770103f29e3eafe616b8e9f9b8a0d60909
MD5 6230973c4c595677cae1f8f36f62da3a
BLAKE2b-256 5db8ad40d910753bc0ead785051f2f6e20dae22cf280d3ce552ca80eadc698dc

See more details on using hashes here.

File details

Details for the file inquant-1.1.8-py3-none-any.whl.

File metadata

  • Download URL: inquant-1.1.8-py3-none-any.whl
  • Upload date:
  • Size: 258.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.18.4 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.5

File hashes

Hashes for inquant-1.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 6541b9ea080e5915d78ff377dd0893fbb065fc8a1064d08e85e5f383969899d3
MD5 0bd45fa255b3c5233d601c0c2789ba8e
BLAKE2b-256 21861b550e8c9f938a1c1bad3697e289f39ada9676b79dcb12d6f8faa82c10e1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page