nash-io / openlimits

A Rust high performance cryptocurrency trading API with support for multiple exchanges and language wrappers.
http://openlimits.io
BSD 2-Clause "Simplified" License
275 stars 44 forks source link

add support for time in force for Nash,Binance and Coinbase #110

Closed jankjr closed 3 years ago

jankjr commented 3 years ago

This PR adds support for TimeInForce. Different exchanges have different ways of supporting this.

I feel the most cross exchange way of supporting this would be to represent the GTC, IOC and FOK as normal enums, and GTT as a duration. This would fit the Coinbase model, and for nash the timestamp can be converted by doing a simple current_time + duration calculation.

pub enum TimeInForce {
    GoodTillCancelled,
    ImmediateOrCancelled,
    FillOrKill,
    // Representing 'good till time' as a duration works for both Nash and Coinbase
    GoodTillTime(Duration),
}

This PR also fixes two bugs I found while testing the Coinbase and Binance implementations. Our naivetimestamp deserialization code sometimes fails if the timestamp lands on a whole milisecond. Our Binance client had an endless loop in the get_all_open_orders call.

closes #104