Skip to main content

-- coding: utf-8 --

from inquant import *

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

def __init__(self,strategyID,logPath):
    """构造函数"""
    super(MyStrategy,self).__init__(strategyID,logPath)
    self.isfirst = 0

def OnTick(self, data):
    """Tick数据处理 注data参数一次只有一条tick数据"""
    self.WriteInfo('tick : {0} {1} {2}'.format(data.Symbol,data.LocalTime,data.Exchange))
    pass

def OnBar(self, data):
    """Bar数据处理 注data参数一次只有一条bar数据"""
    self.WriteInfo('bar : {0} {1} {2}'.format(data.Symbol,data.LocalTime,data.Exchange))

    resp10 = strategy.GetLastBar(data.Symbol,data.Exchange,data.BarType,5)

    if self.isfirst == 0:
        self.isfirst = 1
        resp4 = self.SendOrder(data.Symbol,data.Exchange,OrderSide.Sell,data.LastPx,1,OrderType.LMT,Offset.Close)
    pass

def OnOrderChanged(self,order):
    """成交回报处理"""
    self.WriteInfo('OrderChanged : {0} {1} {2}'.format(order.Symbol,order.Price,order.Exchange))
    pass

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

if name == 'main': #新建策略 strategy = MyStrategy('2-xk1211231243242314123534523453','/home/admin/logs/测试策略/')

strategy.SetMarketStatus(1)

ret = strategy.GetHisBar("rb1905",Exchange.SHFE,60 * 60,1000,20181015150000)

#创建定时任务
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)

a1 = strategy.Subscribe(["rbM.SHFE.Tick.0", "rbM.SHFE.Bar.300"])

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

resp4 = strategy.SendOrder('rb1905',Exchange.SHFE,OrderSide.Buy,0,1,OrderType.MKT,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('rb1905',Exchange.SHFE)
resp9 = strategy.GetLastTick('rb1905',Exchange.SHFE,2)
resp10 = strategy.GetLastBar('rb1905',Exchange.SHFE,300,5)

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

Metadata

Release files for inquant 1.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for inquant 1.3.1
File Size Uploaded Provenance
inquant-1.3.1.tar.gz 17.9 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for inquant 1.3.1
File Interpreter ABI Platform
inquant-1.3.1-py3-none-any.whl Python 3 none any Details

Total release size: 47.6 kB

Release files / inquant-1.3.1.tar.gz

Download URL inquant-1.3.1.tar.gz
Size 17.9 kB
Tags Source
SHA-256 checksum
How to use checksums
0796c34f020d00410987770454e77fb5c57b6ad0f4e5475f42bcdb920957de87
BLAKE2b-256 checksum
How to use checksums
626341b23ea15c89171daed6a6c6e5ea9eb9edada3ebe389dbffd47c930a118d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.4.2 requests/2.19.1 setuptools/41.0.1 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.0

Release files / inquant-1.3.1-py3-none-any.whl

Download URL inquant-1.3.1-py3-none-any.whl
Size 29.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
92872f1537e058874a6512cee428f6c9aab617481159e88fce2ddfe8c9056a65
BLAKE2b-256 checksum
How to use checksums
7c35800a40fba92eaa5f0e8ee31d2fbfc1305bf07463144079703c885d1bb004
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.4.2 requests/2.19.1 setuptools/41.0.1 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.0

Security for inquant 1.3.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page