Automatic position closing after time T+1 ..T+...N


#1

Hi guys.
how can I bind the order to time?
In my strategy, it’s important to hold the position. For example, I need the order to close after 3 hours. Can I do it like that?

Thanks


#2

You have the option to access the dictionary of all the orders created during the algorithm run in context.blotter.orders . You can manually calculate the estimated time in which the order was filled (please note that an order can be filled in phases) by tracking its state.

Lena


#3

Thanks for the answer…

I created a PostgreSQL database where, at each iteration, I recorded transactions, when a signal appears and when it needs to be closed.

I did open orders through the method order(context.btc, 1) and order(context.btc, -1) for close order.
But the results from the database are completely different from the results of the strategy. (different orders)
I checked saved translations, through:
catalyst run -f strategy1.py -x poloniex --start 2018-8-8 --end 2018-8-20 -c usdt --capital-base 100000 -o buy_btc_simple_out.pickle
As a result, I received completely different transactions.
I’m trying to find a bug.

Could there be a bug in your implementation code?


#4

Hi @tt095,

I am not sure I was able to understand the issue you are describing.
If you suspect things are not working as you expect, I suggest you try to create a small example and share it with us with more explanations on what seems to be problematic.

Thanks,
Lena