Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Script Engine: Access to Order Book #984

Open
AwooOOoo opened this issue Aug 16, 2020 · 2 comments
Open

Script Engine: Access to Order Book #984

AwooOOoo opened this issue Aug 16, 2020 · 2 comments
Labels
enhancement New feature or request

Comments

@AwooOOoo
Copy link
Contributor

Is your feature request related to a problem? Please describe.
Allow the script engine to expose access to the orderbook data as seen in the orders window

Describe the solution you'd like
Expose 'orders' object such as;

{
  open: {
    { type: 'SELL', orderState: 'onExchange', limit: '0.65', trigger: '0.65', amount: '100', filled: '0.0'},
    { type: 'SELL', orderState: 'onExchange', limit: '0.75', trigger: '0.75', amount: '100', filled: '0.0'}
  },
  history: [
    { created: '8/16/2020 10:00:00 AM', price: '0.55', amount: '100', fee: '5.5', feeCcy: 'EUR' },
    { created: '8/16/2020 10:05:00 AM', price: '0.45', amount: '100', fee: '4.5', feeCcy: 'EUR' }
  ] 
}

Describe alternatives you've considered
I haven't yet had a chance to look at your internal data structures to see what correct enumerations for different states are; such as is 'SELL' always capitalized, what are the enumeration states for 'orderState' etc?

@AwooOOoo AwooOOoo added the enhancement New feature or request label Aug 16, 2020
@AwooOOoo
Copy link
Contributor Author

Assign this to me, I'll work on it after I finish cleaning up adding balance support (#983).

AwooOOoo added a commit to AwooOOoo/orko that referenced this issue Aug 20, 2020
@AwooOOoo
Copy link
Contributor Author

Some examples for the new support;

Open Orders

var count = 0;

function start() {
  var subscription = events.setOpenOrders(
    function(event) {
      notifications.info("*** OPEN ORDERS: " + event.openOrders());
      
      if (count++ >= 1) {
        control.done()
      }
    },
    parameters.selectedCoin
  );
  
  return RUNNING
}

function stop() {
  events.clear(subscription);  // Stop the subscription
}

Example Response:

Open orders:
[order=LimitOrder [limitPrice=360, Order [type=ASK, originalAmount=10, cumulativeAmount=0, averagePrice=0, fee=0, instrument=ETH/EUR, id=1, timestamp=Thu Aug 20 16:08:14 CEST 2020, status=NEW, flags=[], userReference=175420665]]]
[order=LimitOrder [limitPrice=370, Order [type=ASK, originalAmount=10, cumulativeAmount=0, averagePrice=0, fee=0, instrument=ETH/EUR, id=2, timestamp=Thu Aug 20 16:08:19 CEST 2020, status=NEW, flags=[], userReference=154148732]]]

Order Book

var count = 0;

function start() {
  var subscription = events.setOrderBook(
    function(event) {
      notifications.info("*** OrderBook BIDS: " + event.orderBook().bids);
      notifications.info("*** OrderBook ASKS: " + event.orderBook().asks);
      
      if (count++ >= 1) {
        control.done()
      }
    },
    parameters.selectedCoin
  );
  
  return RUNNING
}

function stop() {
  events.clear(subscription);  // Stop the subscription
}

Example Response:

[LimitOrder [limitPrice=347.77000000, Order [type=BID, originalAmount=0.32508000, cumulativeAmount=null, averagePrice=null, fee=null, instrument=ETH/EUR, id=, timestamp=Thu Aug 20 15:12:35 CEST 2020, status=null, flags=[], userReference=192475211]], LimitOrder [limitPrice=347.75000000, Order [type=BID, originalAmount=0.16254000, cumulativeAmount=null, averagePrice=null, fee=null, instrument=ETH/EUR, id=, timestamp=Thu Aug 20 15:12:37 CEST 2020, status=null, flags=[], userReference=113477373]], LimitOrder [limitPrice=347.56000000, Order [type=BID, originalAmount=1.07717000, cumulativeAmount=null, averagePrice=null, fee=null, instrument=ETH/EUR, id=, timestamp=Thu Aug 20 15:12:26 CEST 2020, status=null, flags=[], userReference=155455028]], LimitOrder [limitPrice=347.38000000, Order [type=BID, originalAmount=2.69161000, cumulativeAmount=null, averagePrice=null, fee=null, instrument=ETH/EUR, id=null, timestamp=null, status=null, flags=[], userReference=115320557]] ...

badgerwithagun added a commit that referenced this issue Aug 29, 2020
* -Fix for #810, wrong message on soft trailing stop.

* -updated orko-parent snapshots

* -Changed the Xchange version from the 5.0.0-SNAPSHOT to 5.0.0

* Commented out Hidden Order integration tests

* -Potential fix for 'Hidden orders' test failure

* -Added Balance support to scripting Engine #983

* -Moved method to Events. (#983)

* -Added Open Order (#984) and Orderbook support to the script script engine

* -UserTrade Support to Script Engine

* -Split 'on' calls (onTick, onBalance, onOpenOrders, onOrderBook, onUserTrades) for clarity

* -Added DisposableSubscription class to clean up subscription cleanup returns.
- Cleaned up some warnings reported by IntelliJ

* - More clean up (missing final's, incorrect pattern usage)

* Review change

* Typo

Co-authored-by: Graham Crockford <[email protected]>
Co-authored-by: Graham Crockford <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant