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.9.tar.gz (254.0 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.9-py3-none-any.whl (259.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: inquant-1.1.9.tar.gz
  • Upload date:
  • Size: 254.0 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.9.tar.gz
Algorithm Hash digest
SHA256 bf01770c875ae176c61bc031a5723f642755bb4a4e6c3df2ea64838de3aa13e2
MD5 7e8fd0c48fcd5a4c242af840852eaced
BLAKE2b-256 2e3541626460bc9d61b89411c8cbb0a698adf65d4b16245375cc9d517509864e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: inquant-1.1.9-py3-none-any.whl
  • Upload date:
  • Size: 259.4 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.9-py3-none-any.whl
Algorithm Hash digest
SHA256 73c1275ca2b333dd25d88fec1c81266ea4319a5292ecc246a5d1d01eed568fe5
MD5 34b9783d581b367a1022cc1a8018b057
BLAKE2b-256 40e534a099f5797df0ed4723510657c67e52fbbd9d22ba7dd55449468f30b50b

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