Giter VIP home page Giter VIP logo

ostia's Introduction

Hi there ๐Ÿ‘‹

Me stats

ostia's People

Contributors

adamlawrencium avatar agundy avatar birchelle avatar mingling94 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ostia's Issues

NPM start?

I ran the NPM Start command, but I am curious as to which port I should access the application at. Here is the output of the command:


 npm start

> [email protected] start /home/ubuntu/Ostia
> node server.js

Cannot GET /index.html

Hi

Im trying to start via the herokaupp link. It returns the overview page but none of the links work and when trying dashboard it returns blank page Cannot GET /index.html

Would be nice to try this one.

Cheers
Daniel

GDAX Parsing not working

For some reason GDAX parsing does not work (ie. the high bid and low ask does not line up with the GDAX website high bid and low ask), this could be for a number of reasons, namely, incorrect mapParsing, incorrect data parsing, or a host of other reasons.

Time scale is off for chart

Chart initializer loads daily closing price data, while updater loads price data every second. So the timestamps are at different 'resolutions' and messes up the charts

Preliminary DataHub structure

Check out this preliminary code snippet for a DataHub structure. Essentially it takes in two arguments, exchanges which is array of exchanges needed, and pairs which is a array of pairs. It also takes in 'all' for either argument to create a structure with all of the pairs/exchanges.

// Info for available pairs in each exchange (needs to be filled out)
var info = {
  poloniex : {
    BTCUSD : "USDT_BTC",
    ETHBTC : "BTC_ETH"
  },
  gdax : {
    BTCUSD : "BTC-USD",
    ETHBTC : "ETH-BTC"
  },
  kraken : {
    BTCUSD : "XXBTZUSD",
    ETHBTC : "XETHXXBT"
  },
  bitfinex : {
    BTCUSD : "BTCUSD",
    ETHBTC : "ETHBTC"
  }
}

// Base order book constructor
let orderbook = function orderbook(pair) {
  return {
    pair : pair,
    last30Day : [],
    currTopOrderBook : [],
    OrderBook : {}
  }
}

// Exchanges constructer
let subSetExchs = function subSetExchs (exchanges, pairs){
  var Exchs = {};
  if (exchanges == 'all'){
    exchanges = ["poloniex", "gdax", "kraken", "bitfinex"];
  }
  for (var i=0; i<exchanges.length ; i++){
    if (info[exchanges[i]]){
        Exchs[exchanges[i]] = subSetExch(exchanges[i], pairs);
    }
  }
  return Exchs;
}

// Single exchange constructor
let subSetExch = function subSetExch (exchange, pairs){
  var Exch = {};
  if (pairs == 'all'){
    pairs = [];
    var i = 0;
    for (var key in info[exchange]){
      if (info[exchange].hasOwnProperty(key)) {
        pairs[i] = key;
        i++;
      }
    }
  }
  for (var i=0; i<pairs.length ; i++){
    if (info[exchange][pairs[i]]){
      Exch[pairs[i]] = orderbook(info[exchange][pairs[i]]);
    }
  }
  return Exch;
}


var exchanges = subSetExchs("all", "all");

var exchanges then contains

{ poloniex: 
   { BTCUSD: 
      { pair: 'USDT_BTC',
        last30Day: [],
        currTopOrderBook: [],
        OrderBook: {} },
     ETHBTC: 
      { pair: 'BTC_ETH',
        last30Day: [],
        currTopOrderBook: [],
        OrderBook: {} } },
  gdax: 
   { BTCUSD: 
      { pair: 'BTC-USD',
        last30Day: [],
        currTopOrderBook: [],
        OrderBook: {} },
     ETHBTC: 
      { pair: 'ETH-BTC',
        last30Day: [],
        currTopOrderBook: [],
        OrderBook: {} } },
  kraken: 
   { BTCUSD: 
      { pair: 'XXBTZUSD',
        last30Day: [],
        currTopOrderBook: [],
        OrderBook: {} },
     ETHBTC: 
      { pair: 'XETHXXBT',
        last30Day: [],
        currTopOrderBook: [],
        OrderBook: {} } },
  bitfinex: 
   { BTCUSD: 
      { pair: 'BTCUSD',
        last30Day: [],
        currTopOrderBook: [],
        OrderBook: {} },
     ETHBTC: 
      { pair: 'ETHBTC',
        last30Day: [],
        currTopOrderBook: [],
        OrderBook: {} } } }

Is this what we are looking for with the OLOO format?

Create Order module

Create a separate file with an Order class that contains utilities for generating proper orders etc...

Designing the strategy trading interface

Now that we have a basic overview of architecture, we need to design how the strategies are actually to trade.

I propose each strategy takes in a config file:

config = {
  strategyName: "EMA",       // exponential moving average
  exchanges:    ["GDAX"],    // exchanges strategy will trade
  pair:         "BTC_ETC",   // or "none" for every pair
  capital:      3000,        // starting capital
  time_frame:   4,           // how long to trade
  blah:         "other param"
}

This creates standardization across all of our strategies and let's others design their own easily as well.
Next we need to initialize the live data sources for the strategy:

var exchange = config.exchanges[0];
var path = "./js/data-parsing/" + exchange + ".js";
var exchange = require(path)(allExchangeData.exchange)

var TradingHub = new TradingHub(config.exchanges[0]);
var DataHub = TradingHub.createOrderbooks();
var orderbook = DataHub.getOrderbooks();

These set up all the data the strategy will ever need to run.
Now that everything it set up, the strategy can run through the data and start its own trading logic . We can decide on a standard for trading logic organization, but for now:
[pseudocode]

function SimpleMovingAverage(orderbooks) {
  // find opportunity
  // import indicators like X-day average
  // create an order object
  var order = {
    pair:   config.pair
    buy:    true,
    sell:   false,
    amount: 100
  }
  return order;
}

// Main 
function main() {
  var start_time = getDate();
  while (start_time - getData() <  time_frame) {    // trade for specified time frame
    if (new_data == true) {
     var order = SimpleMovingAverage(orderbook);
      if (order.buy == true || order.sell == true) {    // see if there's actionable order
        TradingHub.trade(order);    // trade
      }
    }
  }
}
main();
exit(1);

Proposed App Architecture

Overview

(1) DataHub: Basically all the data from the exchange servers can be fed into something called a DataHub - where we store all relevant information any strategy would need about currency pairs. Indicators can either be stored here, or calculated upon a strategy's request (might affect efficiency).

(2) Strategies: The data from DataHub can be called by any strategy. Originally I was thinking about using Websockets to emit all the data, then have the strategies open up listeners based on what data they want. @BirchellE helped me realize that we can just call the all exchange objects since Node keeps everything live and updated.

(3) TradingHub: The strategies then send all their orders to our TradingHub, which contains exchange API wrappers/interfaces. The TradingHub then sends those requests out to the relevant exchanges.

Possible issues:

  • Standardizing exchange data to a universal format that can be used by any strategy.
  • Inefficiencies calculating trading indicators that aren't being used (might be fixable by having strategies calculate them instead).
  • Redundancies involved with creating API wrappers in TradingHub, when API framework might already be available in DataHub.

Overall, I think this architecture provides clean boundaries between our distinct components (modularity), and will allow us to add a backtesting feature or plug-in any exchange or strategy (extensibility) we or a user might need.

ostia archit-2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.