Handling paritally filled orders (by keeping a session object summing amounts and fees across multiple orders)
Using ioc to fill orders (or cancel immediately)
Change orders to ioc flag
[x] Change orders to use time_in_force='ioc' flag which forces orders to be either closed (totally filled) or cancelled (none filled or paritally filled. Both buy and sell side orders will use this new flag by default.
Reasons:
Stops orders from being created with an open status since the asking price was passed over/missed in the volatility of the trading. Worst case, you can buy in successfully and then leave a sell order in an open state.
Using immediate or cancel doesn't require a POST request to cancel the open order each main thread iteration. Any order that the status doesn't come back closed will be automatically cancelled. allowing an immediate place order at the next iteration.
Reslove BALANCE_NOT_ENOUGH issue
[x] You must deflate the sell amount by the fees spent or you will get a 400 error of BALANCE_NOT_ENOUGH.
this error happens on the sell order.
simply put, you need to subtract the fee used to close on the amount you gained.
Add session object / resolves multiple orders due to partial fills
[x] a new session dictionary variable to contain the many possible buy and sell orders the process may take.
[x] at each iteration, the session object will keep a running total of the total_volume, total_amount and total_fees you have collected for as many orders as required.
[x] store session data into session.json at the end of the buy phase and at the end of the sell phase for analysis of transactions
[x] updated test mode to perform a partial fill by default.
[ ] update test mode to perform a partial fill by default. (not ready)
Partial orders / "BALANCE_NOT_ENOUGH" error
Summary
Resolves #54
Change orders to
ioc
flagtime_in_force='ioc'
flag which forces orders to be eitherclosed
(totally filled) orcancelled
(none filled or paritally filled. Both buy and sell side orders will use this new flag by default. Reasons:open
status since the asking price was passed over/missed in the volatility of the trading. Worst case, you can buy in successfully and then leave a sell order in anopen
state.immediate or cancel
doesn't require a POST request to cancel the open order each main thread iteration. Any order that the status doesn't come backclosed
will be automatically cancelled. allowing an immediate place order at the next iteration.Reslove
BALANCE_NOT_ENOUGH
issueBALANCE_NOT_ENOUGH
.Add
session
object / resolves multiple orders due to partial fillssession
dictionary variable to contain the many possible buy and sell orders the process may take.session
object will keep a running total of thetotal_volume
,total_amount
andtotal_fees
you have collected for as many orders as required.session.json
at the end of the buy phase and at the end of the sell phase for analysis of transactions