Cannot subscribe to events problem

All posts which do not fit into any other sections of the forum.

Moderator: admin

Cannot subscribe to events problem

Postby Loggy48 » Fri Nov 25, 2016 12:40 pm

I have a problem which must be in my strategy but I cannot see it.

I am trying to subscribe to events so that I can trace stoploss and other things.

I have a strategy that has been doing this for a long time now without difficulty although it needs some improvement to monitor the CustomID/QTXT so that I avoid interference with any other strategy or manual intervention.

But for some reason I cannot trace the events.

Here is a totally stripped down strategy that doesn't actually trade but should report the events via AsyncOperationFinished:

Code: Select all
function Init()
   strategy:name("Skeleton")
   strategy:description("No flesh")
end
local TRADE_EVENT = 1001
local ORDER_EVENT = 1002
local OFFER_EVENT = 1003
local host = core.host
local period = 0
function Prepare(onlyName)
   instance:name(profile:id() .. "(" .. instance.bid:instrument() .. ")")
   if onlyName then return end
   host:execute("subscribeTradeEvents", OFFER_EVENT , "offers")
   host:execute("subscribeTradeEvents", ORDER_EVENT , "orders")
   host:execute("subscribeTradeEvents", TRADE_EVENT , "trades")   
end
function Update()
   period = period + 1
   xprint("Update entered "..period)
end
function AsyncOperationFinished(cookie, success, message)
   xprint("AOF entered with cookie "..cookie.." success "..success.." message "..message)
end
function xprint(txt)
   host:trace(txt)
end


As I said, very simple. I can import this and run it.

There are no error messages in the event logger other than the message from Update - ie I do not see a message "AOF entered..... " at all which should occcur whenever an offer, order or trade is made on the instrument.

This occurs on two PCs so I don't think it is a PC setting at all and previously it was working perfectly well.
Loggy48
 
Posts: 79
Joined: Tue Jun 24, 2014 8:39 am
Location: Manchester, UK

Re: Cannot subscribe to events problem

Postby Loggy48 » Fri Nov 25, 2016 6:56 pm

(er, yes, it requires a tostring() round the success boolean :) ).

This skeleton strategy (and its more complex relation) appears to work OK both in simulation mode and in backtesting but not on my Demo account on which I was testing it, although I have another strategy that worked OK on the Demo account.

Very puzzling but at least with simulation I can trace what is happening.
Loggy48
 
Posts: 79
Joined: Tue Jun 24, 2014 8:39 am
Location: Manchester, UK


Return to General Discussions

Who is online

Users browsing this forum: No registered users and 2 guests