Threading issue
Threading issue
30 Sep 2013, 19:17
Hi
I am trying to use my own DLL written in C#. The way I do it is as follows:
I make a class in VS which inherites from Robot:
[Robot(TimeZone = TimeZones.UTC)]
public class Strategy:Robot
{
code..
}
Then, I make my cAlgo robot inherit from the above class without defining any events in it.
namespace cAlgo.Robots
{
[Robot(TimeZone = TimeZones.UTC)]
public class Audi : auStrategy
Thus I get all the events in my own class where I develop the robot logic.
Now, it seems that cAlgo fires evey event in its own thread or something like that. Can you point me to information where the cAlgo infrastructure is explained and technical recommendations are given about the implementation of our own bots.
Thanks
Replies
GDPR-24_118209
01 Oct 2013, 15:55
Hi,
Thanks for the confirmation - indeed I found cause of the strange behavior to lie in my own code :) Until I have you on hand, can I ask 2 quick questions:
1. It seems to not be possible to identify the pending order from which a position was opened, right?
2. As I am scalping can you tell me what happens in this situation:
I have a stop buy oder to open at say 1.3550. Ask is currently 1.3548
I want to move the target price of the pending order to 1.3549 - thus, I first send a delete request to delete the existing pending order. First issue here is that the pending order might have become a position during the time I am sending the delete request. What happens in this case - do I get an OnError event?
After I have sent the delete request, I send a new request for buy stop order w/ target price 1.3549. What happens if the Ask has moved to 1.3550 in this time (while I was busy sending the delete request). Will I get an OnError event, or will I get straight OnPositionOpened event without OnPendingOrderCreated?
Thanks but the answers to those questions are very important for me before I move my real robot to cTrader.
Spotware
01 Oct 2013, 16:50
RE:
fx_trader said:
1. It seems to not be possible to identify the pending order from which a position was opened, right?
Right now you can do it using labels. If you specify label for an order position will inherit this label.
First issue here is that the pending order might have become a position during the time I am sending the delete request. What happens in this case - do I get an OnError event?
cAlgo will not notify your robot in case pending order no longer exists.
After I have sent the delete request, I send a new request for buy stop order w/ target price 1.3549. What happens if the Ask has moved to 1.3550 in this time (while I was busy sending the delete request). Will I get an OnError event, or will I get straight OnPositionOpened event without OnPendingOrderCreated?
In this case trade server will fill your order with the current market price.
In your case it would be perfect to use modify order command, but it's not supported now. The only consistent way to implement such robot is to emulate stop orders in cAlgo, I mean to send market orders when spot price reaches certain level and use VPS to minimize possible latency. Note that if you use market orders you can also specify maximum slippage in pips.
We currently work on new trading API that will be much more flexible and allow to modify pending orders and handle errors properly.
@Spotware
GDPR-24_118209
30 Sep 2013, 22:12
RE:
Or to put the question differently: Does cAlgo use synchronous or asynchronous events?