-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
154 additions
and
3 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
phoenix/src/main/java/com/mmorrell/phoenix/model/ImmediateOrCancelOrderPacketRecord.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.mmorrell.phoenix.model; | ||
|
||
import lombok.Builder; | ||
import lombok.Data; | ||
|
||
import java.nio.ByteBuffer; | ||
import java.nio.ByteOrder; | ||
|
||
@Data | ||
@Builder | ||
public class ImmediateOrCancelOrderPacketRecord { | ||
|
||
private byte side; | ||
private long priceInTicks; | ||
private long numBaseLots; | ||
private long numQuoteLots; | ||
private long minBaseLotsToFill; | ||
private long minQuoteLotsToFill; | ||
private byte selfTradeBehavior; | ||
private long matchLimit; | ||
private byte[] clientOrderId; | ||
private boolean useOnlyDepositedFunds; | ||
|
||
public byte[] toBytes() { | ||
ByteBuffer buffer = ByteBuffer.allocate(63); | ||
buffer.order(ByteOrder.LITTLE_ENDIAN); | ||
|
||
buffer.put(0, side); | ||
buffer.put(1, (byte) 1); // coption for present = 1 | ||
buffer.putLong(2, side == 0 ? 4503599627370496L : 0x00); | ||
buffer.putLong(10, 0x00); //numBaseLots | ||
buffer.putLong(18, numQuoteLots); | ||
buffer.putLong(26, 0x00); // min base lots to fill | ||
buffer.putLong(34, 0x00); // quote lots to Fill | ||
buffer.put(42, selfTradeBehavior); | ||
buffer.put(43, (byte) 0); // coption for not present = 0 | ||
// buffer.putLong(44, matchLimit); // skip matchLimit since it's coption is 0 | ||
buffer.put(44, clientOrderId); // go straight to clientOrderId from the coption 0 byte | ||
buffer.put(60, useOnlyDepositedFunds ? (byte) 1 : (byte) 0); | ||
buffer.put(61, (byte) 0); // coption for lastValidSlot (0 = ignored) | ||
buffer.put(62, (byte) 0); // coption for lastValidUnixTimestampInSeconds | ||
|
||
return buffer.array(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters