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
273 stars 44 forks source link

Ligen #192

Closed notdanilo closed 2 years ago

notdanilo commented 2 years ago

WIP

Build depends on https://github.com/sensorial-systems/ligen (branch: ligen-csharp) in the parent folder.

Output can be found in crates/openlimits-exchange/target/ligen/openlimits-exchange/

notdanilo commented 2 years ago

From this commit, we are able to generate this file from candle.rs:

namespace OpenlimitsExchange
{
    using System.Runtime.InteropServices;
    [StructLayout(LayoutKind.Sequential, Pack = 1)]
    public struct Candle
    {
        public readonly u64 time;
        public readonly Decimal low;
        public readonly Decimal high;
        public readonly Decimal open;
        public readonly Decimal close;
        public readonly Decimal volume;

        public Candle(u64 time, Decimal low, Decimal high, Decimal open, Decimal close, Decimal volume)
        {
            this.time = time;
            this.low = low;
            this.high = high;
            this.open = open;
            this.close = close;
            this.volume = volume;
        }
    }
}

which is partially similar to this file https://github.com/nash-io/openlimits-csharp/blob/master/OpenLimits/Candle.cs

We still need to adapt the namespace and provide a way to marshal arbitraty types -- in this case Decimal to double.

notdanilo commented 2 years ago

Including enumerations and more structures.