The resource loading... loading...

Requesting assistance: Questions regarding the procurement and sale of contracts and handling of outstanding orders

Author: xionglonghui, Created: 2021-09-19 21:43:39, Updated:

I used to write strategies in Ma, a very simple language that can implement strategies very quickly, but I couldn't expand it later, and I wanted to add some other features that I couldn't do, but now I'm re-implementing the previous strategy with JS, but I'm having a few problems:

The first problem is that in the case of the Ma language, they buy open positions and sell close positions, they go for a limited price listing order, but the limited price is a real-time CLOSE offer or buy one price, sell one price.

The logic I'm implementing now with JS is: hang orders with the latest real-time close price + slider at the time of purchase, but there will be outstanding orders.

But I use the following code, and it will get an error whenever I come across no pending orders. Shows TypeError: Cannot read properties of undefined (reading Id). I have a problem with this.

var wei_order = exchange.GetOrders ((); // Unfinished orders

while (wei_order)
// I tried to solve with while (wei_order!=[]) or while (wei_order!=null) and still can't, my idea is that the wei_order variable only handles pending orders // However, this while condition does not work, it will return an error: TypeError: Cannot read properties of undefined (reading Id), and I want to cancel the order only when there is no completed order, and re-order at a higher price. {pos (192,210) } var we_order_id = we_order[0].Id; We have a list of all the different ways to cancel an order.
Sleep(1000); order_id = exchange.Buy(now_records.Close+ huadian, KaiCangNum); Sleep(5000); }

The second problem: because there are pending orders, so I use the exchange.GetPosition))) function to get the number of holds, and when I sell, I find out that there are not enough pending orders. I'm curious, is the amount in the exchange.GetPosition))) function not the amount that has already been successfully held?

The third question: how to order in case of outsourcing of purchase and sale orders (not wanting to order at the market price), how to deal with outstanding orders (trying again several times, how long the interval), how to keep the profits (not wanting to order at the market price) How do you make sure that the number of positions you have is correct, without showing that the number of positions you have is insufficient?


More

caibingbo7639How did you end up solving the problem of not having enough transactions?

syueThe submission returns an orderid, and the writer enters the loop to track the ORDER ID transaction, otherwise it will be deleted in 2 seconds.