Make c# api friendlier to immutable types. Rename Result.result to Result.value

This commit is contained in:
Eric Harding committed 2017-11-10 11:18:45 -05:00
1 parent b7b3cbb59d
commit eafa6ed68d
18 files changed
+221 -189

No files matched your search

@@ -115,7 +115,7 @@ namespace mbts.spark
public const int Version = 1;
public StartupData() { }
public StartupData(Security[] securities, SortingCriteria[] sorting_criteria) {
if (securities != null) this.securities = securities.Select(s => s.ToByteArray()).ToArray();
if (securities != null) this.securities = securities.Select(s => ((IImmutableMessage)s).ToByteArray()).ToArray();
this.sorting_criteria = sorting_criteria;
}
[ProtoMember(1)]
@@ -128,7 +128,7 @@ namespace mbts.spark
public const int Version = 1;
public StartupData() { }
public StartupData(IReadOnlyCollection<Security> securities, SortingCriteria[] sorting_criteria) {
if (securities != null) this.securities = securities.Select(s => s.ToByteArray()).ToArray();
if (securities != null) this.securities = securities.Select(s => ((IImmutableMessage)s).ToByteArray()).ToArray();
this.sorting_criteria = sorting_criteria;
}
[ProtoMember(1)]
@@ -32,7 +32,7 @@ namespace mbts.spark
while (curr_secmap.Contains(id)) id--;
synthetic.Id = id;
var sec_strategy = new SyntheticExecutionStrategy { Security = synthetic, ExecutionStrategy = strategy };
_bus.post(SparkTags.PersistCommandTag, new SparkBusData.PersistMessage(1, "SyntheticSecurity", String.Empty, sec_strategy.ToByteArray()));
_bus.post(SparkTags.PersistCommandTag, new SparkBusData.PersistMessage(1, "SyntheticSecurity", String.Empty, ((IImmutableMessage)sec_strategy).ToByteArray()));
} else {
// MODIFY
}
@@ -111,7 +111,7 @@ namespace mbts.spark
public const int Version = 1;
public StartupData() { }
public StartupData(IReadOnlyCollection<Security> securities, SortingCriteria[] sorting_criteria) {
if (securities != null) this.securities = securities.Select(s => s.ToByteArray()).ToArray();
if (securities != null) this.securities = securities.Select(s => ((IImmutableMessage)s).ToByteArray()).ToArray();
this.sorting_criteria = sorting_criteria;
}
[ProtoMember(1)]
+1 -1
View File
@@ -72,7 +72,7 @@ namespace mbts.api.Test {
var h = _context.locate<HelloService>();
TableUpdate<HelloLog, string> last_update = null;
using (var sub1 = h.subscribe_greetings().table().Subscribe(t => last_update = t)) {
using (var sub1 = h.subscribe_greetings().Table().Subscribe(t => last_update = t)) {
var response = h.say_hello(new HelloRequest() { Name = "UnitTest 1" });
Assert.AreEqual("Hello UnitTest 1", response.Message);
@@ -31,10 +31,10 @@ namespace bts.api.core
var resp = await _shout.upper_async(new ShoutRequest() { Msg = msg });
// Yell so loud you can't hear the last message
_gpub.publish(
added: new List<HelloLog> { new HelloLog() { Myid = (++id).ToString(), Message = resp.result.MSG } },
added: new List<HelloLog> { new HelloLog() { Myid = (++id).ToString(), Message = resp.value.MSG } },
removed: new HashSet<string> { (id - 1).ToString() });
switch (resp.success) {
case true: return new HelloResponse() { Message = resp.result.MSG };
case true: return new HelloResponse() { Message = resp.value.MSG };
default: return new HelloResponse() { Message = "Sorry {0}. We cannot yell at you right now.".fmt(request.Name) };
}
}
+4 -4
View File
@@ -50,9 +50,9 @@ namespace mbts.persist
Ns = uns(ns),
Key = { key }
});
check_error(ret.result.Result, ns, key, out bool empty);
check_error(ret.value.Result, ns, key, out bool empty);
if (empty) return default(T);
return deserialize<T>(ret.result.Record.Single().Value);
return deserialize<T>(ret.value.Record.Single().Value);
}
private Google.Protobuf.ByteString serialize<T>(T obj) {
@@ -90,9 +90,9 @@ namespace mbts.persist
new RetrieveAllRequest() {
Ns = uns(ns)
});
check_error(results.result.Result, ns, "", out bool empty);
check_error(results.value.Result, ns, "", out bool empty);
if (empty) return Enumerable.Empty<PersistResult<T>>();
return results.result.Record
return results.value.Record
.Where(r => re.IsMatch(r.Key))
.Select(r => new PersistResult<T>() {
user = user(),
@@ -26,7 +26,7 @@ namespace mbts.ui.settings
async Task<string[]> get_users(UserService login) {
var users = await login.get_users_async(null);
if (users.success) return users.result.Users.Select(x => x.Login).ToArray();
if (users.success) return users.value.Users.Select(x => x.Login).ToArray();
else return new string[0];
}
@@ -105,7 +105,7 @@ namespace mbts.ui.shell
_enum_workspace = new PreloginWorkspaceEnumerator(persist);
var response = await _logon.get_users_async(new GetUsersRequest());
if (response.success) {
UserNames = response.result.Users.Select(x => x.Login).ToArray();
UserNames = response.value.Users.Select(x => x.Login).ToArray();
Array.Sort(UserNames);
}
else {
@@ -127,13 +127,13 @@ namespace mbts.ui.shell
Password = password ??""
});
if (response.success) {
if (response.result.IsValid) {
if (response.value.IsValid) {
_workspace = workspace;
set_authenticated_user(username);
return (true, "");
}
else {
return (false, response.result.Reason);
return (false, response.value.Reason);
}
}
else {
@@ -50,18 +50,18 @@ namespace bts.api.core {
return tcs.Task;
}
public unsafe override IObservable<RawUpdate<T>> subscribe<T>(string method_and_qualifier, MessageParser<T> parser) {
public unsafe override IObservable<RawUpdate<TOut>> subscribe<TParse,TOut>(string method_and_qualifier, MessageParser<TParse> parser, Func<TParse,TOut> converter) {
bool first_update = true;
var result = Observable.Create<RawUpdate<T>>(observer => {
var result = Observable.Create<RawUpdate<TOut>>(observer => {
ApiNativeMethods.raw_subscription_callback cb = (event_type, changes, change_count, unused) => {
if (event_type == ApiNativeMethods.EventType.TABLE_UPDATED) {
var added_items = new List<T>(change_count);
var added_items = new List<TOut>(change_count);
var added_keys = new List<int>(change_count);
var removed_keys = new List<int>(change_count);
foreach (var change in changes) {
if (change.type != ApiNativeMethods.ChangeType.REMOVE) {
// create or change
added_items.Add(parser.ParseFrom(new UnmanagedMemoryStream(change.buffer, change.buffer_len)));
added_items.Add( converter( parser.ParseFrom(new UnmanagedMemoryStream(change.buffer, change.buffer_len))));
added_keys.Add(change.key);
}
if (change.type != ApiNativeMethods.ChangeType.CREATE) {
@@ -69,11 +69,11 @@ namespace bts.api.core {
removed_keys.Add(change.key);
}
}
observer.OnNext(new RawUpdate<T>(added_items, added_keys, removed_keys));
observer.OnNext(new RawUpdate<TOut>(added_items, added_keys, removed_keys));
}
else if (event_type == ApiNativeMethods.EventType.TABLE_CREATED) {
if (!first_update) {
observer.OnNext(RawUpdate<T>.Reset());
observer.OnNext(RawUpdate<TOut>.Reset());
}
first_update = false;
}
+15 -15
View File
@@ -1,21 +1,21 @@
using Google.Protobuf;
using System;
using System.Threading.Tasks;
namespace bts.api.core {
internal abstract class ClientChannel : IDisposable
using Google.Protobuf;
using System;
using System.Threading.Tasks;
namespace bts.api.core {
internal abstract class ClientChannel : IDisposable
{
readonly ServiceContext _context;
public ClientChannel(ServiceContext context) {
_context = context;
}
public abstract void Dispose();
public abstract Task<Result<Response>> send<Request, Response>(int method_id, Request request)
}
public abstract void Dispose();
public abstract Task<Result<Response>> send<Request, Response>(int method_id, Request request)
where Request: IImmutableMessage where Response : class,IMessage,new();
public abstract IObservable<RawUpdate<T>> subscribe<T>(string method_and_qualifier, MessageParser<T> parser)
where T : IMessage<T>;
public abstract bool is_sync_call_ok();
}
}
public abstract IObservable<RawUpdate<TOut>> subscribe<TParse,TOut>(string method_and_qualifier, MessageParser<TParse> parser, Func<TParse,TOut> converter=null)
where TParse : IMessage<TParse>;
public abstract bool is_sync_call_ok();
}
}
+41 -41
View File
@@ -3,44 +3,44 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace bts.api.core
{
public struct Result<T>
{
public Result(T v) {
_result = v;
_code = ApiError.Success;
}
public Result(ApiError code) {
System.Diagnostics.Debug.Assert(code != ApiError.Success);
_code = code;
_result = default(T);
}
private string error_string(ApiError code) {
switch (code) {
case ApiError.Success: return "Success";
case ApiError.NoServer: return "No server found.";
case ApiError.ServerDisconnect: return "Server disconnected.";
case ApiError.MissingMethod: return "Method not found.";
case ApiError.ServerFault: return "Server error.";
default: return "Unknown error";
}
}
readonly T _result;
readonly ApiError _code;
public T result {
get {
if (success) return _result;
else throw new ApiException(error_message);
}
}
public bool success { get { return _code == ApiError.Success; } }
public ApiError code { get { return _code; } }
public string error_message { get { return error_string(_code); } }
}
}
namespace bts.api.core
{
public struct Result<T>
{
public Result(T v) {
_result = v;
_code = ApiError.Success;
}
public Result(ApiError code) {
System.Diagnostics.Debug.Assert(code != ApiError.Success);
_code = code;
_result = default(T);
}
private string error_string(ApiError code) {
switch (code) {
case ApiError.Success: return "Success";
case ApiError.NoServer: return "No server found.";
case ApiError.ServerDisconnect: return "Server disconnected.";
case ApiError.MissingMethod: return "Method not found.";
case ApiError.ServerFault: return "Server error.";
default: return "Unknown error";
}
}
readonly T _result;
readonly ApiError _code;
public T value {
get {
if (success) return _result;
else throw new ApiException(error_message);
}
}
public bool success { get { return _code == ApiError.Success; } }
public ApiError code { get { return _code; } }
public string error_message { get { return error_string(_code); } }
}
}
+88 -88
View File
@@ -1,85 +1,85 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Reactive.Linq;
namespace bts.api.core {
public struct RawUpdate<T> {
// RawUpdate uses List<T> instead of IReadonlyList to avoid virtual dispatch on a type not likely to be see in a public api surface
public RawUpdate(List<T> added_items, List<int> added_keys, List<int> removed_keys) : this() {
is_reset = false;
this.added_items = added_items;
this.added_keys = added_keys;
this.removed_keys = removed_keys;
}
public static RawUpdate<T> Reset() {
return new RawUpdate<T>() { is_reset = true };
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Reactive.Linq;
public bool is_reset;
public List<T> added_items { get; private set; }
public List<int> added_keys { get; private set; }
public List<int> removed_keys { get; private set; }
}
public class Update<T, TKey> where TKey : IEquatable<TKey> {
private Func<T, TKey> _key;
public Update(IEnumerable<T> all, IReadOnlyList<T> added, IReadOnlyList<T> removed, Func<T, TKey> key_extractor) {
this.added = added;
this.removed = removed;
this.all = all;
_key = key_extractor;
}
public IEnumerable<T> all { get; private set; }
public IReadOnlyList<T> added { get; private set; }
public IReadOnlyList<T> removed { get; private set; }
public TKey key(T t) { return _key(t); }
}
public class TableUpdate<T, TKey> where TKey : IEquatable<TKey> {
readonly Dictionary<TKey, T> _state;
readonly IReadOnlyList<T> _added;
readonly IReadOnlyList<T> _removed;
internal TableUpdate(Dictionary<TKey, T> init, IReadOnlyList<T> added, IReadOnlyList<T> removed) {
_state = init;
_added = added;
_removed = removed;
}
public IReadOnlyDictionary<TKey, T> state { get { return _state; } }
public IReadOnlyList<T> added { get { return _added; } }
public IReadOnlyList<T> removed { get { return _removed; } }
public TableUpdate<T, TKey> update(Update<T, TKey> update) {
var table = new TableUpdate<T, TKey>(new Dictionary<TKey, T>(_state), update.added, update.removed);
foreach (var i in update.removed) {
table._state.Remove(update.key(i));
}
foreach (var item in update.added) {
table._state.Add(update.key(item), item);
}
return table;
}
}
public static class ObservableUpdateExtensions {
public static IObservable<Update<T, TKey>> reconstitute<T, TKey>(this IObservable<RawUpdate<T>> source, Func<T, TKey> key_extractor) where TKey : IEquatable<TKey> {
var state = new Dictionary<int, T>();
return source.Select(raw => {
namespace bts.api.core {
public struct RawUpdate<T> {
// RawUpdate uses List<T> instead of IReadonlyList to avoid virtual dispatch on a type not likely to be see in a public api surface
public RawUpdate(List<T> added_items, List<int> added_keys, List<int> removed_keys) : this() {
is_reset = false;
this.added_items = added_items;
this.added_keys = added_keys;
this.removed_keys = removed_keys;
}
public static RawUpdate<T> Reset() {
return new RawUpdate<T>() { is_reset = true };
}
public bool is_reset;
public List<T> added_items { get; private set; }
public List<int> added_keys { get; private set; }
public List<int> removed_keys { get; private set; }
}
public class Update<T, TKey> where TKey : IEquatable<TKey> {
private Func<T, TKey> _key;
public Update(IReadOnlyCollection<T> all, IReadOnlyList<T> added, IReadOnlyList<T> removed, Func<T, TKey> key_extractor) {
this.added = added;
this.removed = removed;
this.all = all;
_key = key_extractor;
}
public IReadOnlyCollection<T> all { get; private set; }
public IReadOnlyList<T> added { get; private set; }
public IReadOnlyList<T> removed { get; private set; }
public TKey key(T t) { return _key(t); }
}
public class TableUpdate<T, TKey> where TKey : IEquatable<TKey> {
readonly Dictionary<TKey, T> _state;
readonly IReadOnlyList<T> _added;
readonly IReadOnlyList<T> _removed;
internal TableUpdate(Dictionary<TKey, T> init, IReadOnlyList<T> added, IReadOnlyList<T> removed) {
_state = init;
_added = added;
_removed = removed;
}
public IReadOnlyDictionary<TKey, T> state { get { return _state; } }
public IReadOnlyList<T> added { get { return _added; } }
public IReadOnlyList<T> removed { get { return _removed; } }
public TableUpdate<T, TKey> update(Update<T, TKey> update) {
var table = new TableUpdate<T, TKey>(new Dictionary<TKey, T>(_state), update.added, update.removed);
foreach (var i in update.removed) {
table._state.Remove(update.key(i));
}
foreach (var item in update.added) {
table._state.Add(update.key(item), item);
}
return table;
}
}
public static class ObservableUpdateExtensions {
public static IObservable<Update<T, TKey>> reconstitute<T, TKey>(this IObservable<RawUpdate<T>> source, Func<T, TKey> key_extractor) where TKey : IEquatable<TKey> {
var state = new Dictionary<int, T>();
return source.Select(raw => {
if (raw.is_reset) {
var removed = state.Values.ToList();
state.Clear();
return new Update<T, TKey>(new T[0], new T[0], removed, key_extractor);
}
}
else {
var removed = new List<T>(raw.removed_keys.Count);
foreach (var r in raw.removed_keys) {
@@ -93,14 +93,14 @@ namespace bts.api.core {
state[raw.added_keys[x]] = raw.added_items[x];
}
return new Update<T, TKey>(state.Values, raw.added_items, removed, key_extractor);
}
});
}
public static IObservable<TableUpdate<T,TKey>> table<T,TKey>(this IObservable<Update<T,TKey>> source) where TKey : IEquatable<TKey> {
return source.Scan(
new TableUpdate<T,TKey>(new Dictionary<TKey, T>(), new List<T>(), new List<T>()),
(table, update) => table.update(update));
}
}
}
}
});
}
public static IObservable<TableUpdate<T,TKey>> Table<T,TKey>(this IObservable<Update<T,TKey>> source) where TKey : IEquatable<TKey> {
return source.Scan(
new TableUpdate<T,TKey>(new Dictionary<TKey, T>(), new List<T>(), new List<T>()),
(table, update) => table.update(update));
}
}
}
@@ -7,7 +7,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace bts {
namespace bts.api {
internal interface IImmutableMessage {
MessageDescriptor Descriptor { get; }
int CalculateSize();
+10 -4
View File
@@ -77,11 +77,19 @@ EnumModel = namedtuple("EnumModel", "name values")
def transform_enum(e):
return EnumModel(e.name, [])
MessageModel = namedtuple("MessageModel", "name field nested_type nested_enum")
OneofModel = namedtuple("OneofModel", "name Name")
def transform_oneof(o, msg):
return OneofModel(
name = o.name,
Name = o.name[0].upper() + o.name[1:]
)
MessageModel = namedtuple("MessageModel", "name field oneof nested_type nested_enum")
def transform_message(i):
r = MessageModel(
name = i.name,
field = [transform_field(f,i) for f in i.field],
oneof = [transform_oneof(o,i) for o in i.oneof_decl],
nested_type = [transform_message(m) for m in i.nested_type],
nested_enum = [transform_enum(e) for e in i.enum_type],
)
@@ -98,12 +106,11 @@ def transform_service(service, keymap):
FileModel = namedtuple("FileModel", "name package namespace_csharp message_type service enum_type")
def transform_file(p, keymap):
message_types = [transform_message(m) for m in p.message_type]
return FileModel(
name = p.name,
package = p.package,
namespace_csharp = p.package,
message_type = message_types,
message_type = [transform_message(m) for m in p.message_type],
service = [transform_service(s, keymap) for s in p.service],
enum_type = [transform_enum(e) for e in p.enum_type]
)
@@ -206,7 +213,6 @@ def generate_insertions(params, request, response):
def camel_case(item):
if item.isupper() and not '_' in item: return item
return item.title().replace('_', '')
return d
def generate_code(request, response):
@@ -20,20 +20,37 @@ public sealed class {{name}} : IApiClient, IDisposable {
{{#if server_streaming}}
// {{comment}}
public IObservable<Update<{{output_type_full}},{{key_type.cstype}}>> subscribe_{{name}}({{input_type_full}} qualifier=null) {
return _channel.subscribe<{{output_type_full}}>(ApiServer.format_qualifier("{{name}}",qualifier), {{output_type_full}}.Parser).reconstitute(key);
return _channel.subscribe<{{output_type_full}}, {{output_type_full}}>(ApiServer.format_qualifier("{{name}}",qualifier), {{output_type_full}}.Parser, a=>a).reconstitute(key);
}
internal IObservable<Update<{{output_type_full}}Immutable,{{key_type.cstype}}>> subscribei_{{name}}({{input_type_full}} qualifier=null) {
return _channel.subscribe<{{output_type_full}}, {{output_type_full}}Immutable>(ApiServer.format_qualifier("{{name}}",qualifier), {{output_type_full}}.Parser, a=>({{output_type_full}}Immutable)a).reconstitute(key);
}
private static {{key_type.cstype}} key({{output_type_full}} row) {
return row.{{camel key_field}};
}
private static {{key_type.cstype}} key({{output_type_full}}Immutable row) {
return row.{{camel key_field}};
}
{{else}}
// {{comment}}
public Task<Result<{{output_type_full}}>> {{name}}_async({{input_type_full}} request) {
return _channel.send<{{input_type_full}},{{output_type_full}}>({{@index}}, request);
}
internal Task<Result<{{output_type_full}}>> {{name}}_async({{input_type_full}}Immutable request) {
return _channel.send<{{input_type_full}}Immutable,{{output_type_full}}>({{@index}}, request);
}
// {{comment}}
public {{output_type_full}} {{name}}({{input_type_full}} request) {
if (_channel.is_sync_call_ok()) {
return {{name}}_async(request).Result.result;
return {{name}}_async(request).Result.value;
}
else {
throw new bts.api.core.ApiException("API blocking call cannot be made on this thread. Please use {{name}}_async instead.");
}
}
internal {{output_type_full}} {{name}}({{input_type_full}}Immutable request) {
if (_channel.is_sync_call_ok()) {
return {{name}}_async(request).Result.value;
}
else {
throw new bts.api.core.ApiException("API blocking call cannot be made on this thread. Please use {{name}}_async instead.");
@@ -8,14 +8,14 @@ using Google.Protobuf.WellKnownTypes;
namespace {{package}} {
{{#each message_type}}
partial class {{name}} : bts.IImmutableMessage {
MessageDescriptor bts.IImmutableMessage.Descriptor => {{name}}.Descriptor;
partial class {{name}} : bts.api.IImmutableMessage {
MessageDescriptor bts.api.IImmutableMessage.Descriptor => {{name}}.Descriptor;
}
partial struct {{name}}Immutable : bts.IImmutableMessage {
partial struct {{name}}Immutable : bts.api.IImmutableMessage {
readonly {{name}} _impl;
public static MessageDescriptor Descriptor => {{name}}.Descriptor;
MessageDescriptor bts.IImmutableMessage.Descriptor => {{name}}.Descriptor;
MessageDescriptor bts.api.IImmutableMessage.Descriptor => {{name}}.Descriptor;
public int CalculateSize() => _impl.CalculateSize();
public void WriteTo(CodedOutputStream output) => _impl.WriteTo(output);
@@ -42,8 +42,12 @@ namespace {{package}} {
public bool Equals({{name}}Immutable other) {
return _impl.Equals(other._impl);
}
partial void EqualsOverride(ref bool didrun, ref bool result, {{name}}Immutable other);
public bool Equals({{name}}Immutable? other) {
if (other == null) return false;
bool didrun = false, result = false;
EqualsOverride(ref didrun, ref result, other.Value);
if (didrun) return result;
return _impl.Equals(other.Value._impl);
}
public override int GetHashCode() => _impl.GetHashCode();
@@ -68,6 +72,11 @@ namespace {{package}} {
{{/if}}
{{/each}}
// oneof enums
{{#each oneof}}
public {{../name}}.{{Name}}OneofCase {{Name}}Case => _impl.{{Name}}Case;
{{/each}}
public {{name}}Immutable with(
// Arguments
+13 -13
View File
@@ -29,7 +29,7 @@ message Order {
}
TimeInForce time_in_force = 50;
uint64 timestamp = 60;
oneof algo_order_type {
oneof AlgoOrderType {
MarketOrder market_order = 100;
LimitOrder limit_order = 110;
StopMarketOrder stop_market_order = 120;
@@ -144,7 +144,7 @@ message BTSShootTillHitOrder
/// Only support a limit or market as Retry's
/// We can make Retry a general parameter for
/// every order
oneof native_order_type
oneof NativeOrderType
{
MarketOrder market_order = 10;
LimitOrder limit_order = 20;
@@ -171,7 +171,7 @@ message BTSWithATickParameters
message BTSWithATickOrder
{
BTSWithATickParameters order_parameters = 10;
oneof native_order_type
oneof NativeOrderType
{
LimitOrder limit_order = 20;
}
@@ -202,7 +202,7 @@ message BTSTimedWindowParameters
message BTSTimedWindowOrder
{
BTSTimedWindowParameters order_parameters = 10;
oneof native_order_type
oneof NativeOrderType
{
MarketOrder market_order = 20;
LimitOrder limit_order = 30;
@@ -245,12 +245,12 @@ When the market penetrates the trigger price, a limit order is sent "payup" tick
message BTSStopOrder
{
PriceTrigger price_trigger = 10;
oneof native_trigger_order_type
oneof NativeTriggerOrderType
{
MarketOrder market_order = 20;
LimitOrder limit_order = 30;
}
oneof trigger_order_price
oneof TriggerOrderPrice
{
PriceOffset payup = 40;
double price = 50;
@@ -269,12 +269,12 @@ Opposite of BTS Stop (Both in terms of where the order is placed, and how it tra
message BTSIfTouchedOrder
{
PriceTrigger price_trigger = 10;
oneof native_trigger_order_type
oneof NativeTriggerOrderType
{
MarketOrder market_order = 20;
LimitOrder limit_order = 30;
}
oneof order_price
oneof OrderPrice
{
PriceOffset payup = 40;
double price = 50;
@@ -293,7 +293,7 @@ previous has been filled.
message BTSIcebergOrder
{
QuantityMeasure display_quantity = 10;
oneof child_order_offset
oneof ChildOrderOffset
{
PriceOffset market_offset = 20;
double diff_from_last_fill = 30;
@@ -312,7 +312,7 @@ message BTSTimeSliceOrder
{
double interval = 10;
QuantityMeasure display_quantity = 20;
oneof child_order_type
oneof ChildOrderType
{
MarketOrder market_order = 30;
LimitOrder limit_order = 40;
@@ -320,7 +320,7 @@ message BTSTimeSliceOrder
PriceOffset child_order_offset = 50;
/// the earlier order can either be left, or its
/// price moved toward the inside market by payup_ticks
oneof left_over_action
oneof LeftOverAction
{
bool leave = 60;
double payup_ticks = 70;
@@ -343,12 +343,12 @@ ii. If the stop order is trigerred, the Limit order is cancelled
message BTSOCOOrder
{
PriceTrigger price_trigger = 10;
oneof native_trigger_order_type
oneof NativeTriggerOrderType
{
MarketOrder market_order = 20;
LimitOrder limit_order = 30;
}
oneof order_price
oneof OrderPrice
{
PriceOffset payup = 40;
double price = 50;