Closed P9avel closed 1 year ago
@P9avel OrderId, Price and Quantity types abstracts actual type, you could modify underlying type of OrderId, Price or Quantity based on your needs.
Not undertood, sorry. Please look code
public class Order { public bool IsBuy { get; set; } public OrderId OrderId { get; set; }
I am cannot replace OrderId here. Need rewrite all
you could change underlying type. of order id, also you need to change serializer to match with underlying type.
public readonly struct OrderId : IEquatable<OrderId>, IComparable<OrderId>
{
public const int SizeOfOrderId = sizeof(long);
public static readonly OrderId MaxValue = long.MaxValue;
public static readonly OrderId MinValue = long.MinValue;
private readonly long _orderId;
public OrderId(long orderId)
{
_orderId = orderId;
}
// rest of the code
}
Many thanks, now understand. Possible you can add this code to repository, I am think ulong for OrderId is best solution for Exchange implementation
I see you. But i am want to use your code as is and update when you will release new version without modification.
I see,
@P9avel long for OrderId seems good data type. We should probably use long as internal type. But do you think that we should give a choice to developers to use type of their choice. There might be some advantages of this
Your thoughts?
Possible implement OrderId as Generic? And implement default internal type as long?
If we use generic then it would be hard to restrict to just numeric types, short, int, long, decimal. This applies to other types as well, Mostly shares are traded in full number only, some developers might prefer using int for underlying datatype for Quantity.
some developers might prefer using int for underlying datatype for Quantity Yes, you a right. But int value we can save to decimal and can used Validation for exclude real values. But with OrderId issue many complex. If we used int, then can saved 0...2 147 483 647 orders. For example many large exchanges guarantee matching 60000 orders per second. In result int give 2 147 483 647/60000 = 35791,39 seconds = 9,9hours. I am want to save orderId in database and long best solution in any case
@P9avel I have refactored code, so that It makes easy to choose underlying types. Now you will need to change just OrderId structure, we have moved serialization and deserialization methods to OrderId structure. it is now more cohesive by design.
I am thinking of redesigning Order class and common types. so that choosing right type would be easier as well as more efficient.
see #49
Many thanks for this!!!
I am thinking of redesigning Order class and common types Possible can you add new unit test for custom Order implementation with long orderid and with userId property when complete?
@P9avel Sure.
@P9avel long-orderId-and-userId branch contains support for UserId and OrderId in long.
Many many thx for your work
I am think complete and you can close issue
I am planed to have 1million orders per sec. And int can finished very quickly