joeldg/bowhead

Method does not exist (markOHLC)

Opened this issue · 3 comments

Assuming GdaxScalperCommand.php needs a tweak but not sure where/how.

Tried this:

`$ php artisan bowhead:gdax_scalper`

Resulted in:

------------------------------------------------------------------
Set CBURL to api-public.sandbox.gdax.com before running this..
This will trade live otherwise, so be CAREFUL
PRESS ENTER TO CONTINUE
------------------------------------------------------------------

UPDATING RECENT Open, High, Low, Close data

In Macroable.php line 99:
                                                                               
  Method Bowhead\Console\Commands\GdaxScalperCommand::markOHLC does not exist  

Relevant portion of GdaxScalperCommand.php:

        echo $this->console->colorize("UPDATING RECENT Open, High, Low, Close data\n");
        $_trades = $this->coinbase->get_endpoint('trades',null,null,'ETH-USD');
        $totalsize = $trades = [];
        $total = count($_trades);
        $i = 1;
        foreach($_trades as $tr) {
            $dates = date_parse($tr['time']);
            $timeid = $dates['year'].str_pad($dates['month'],2,0,STR_PAD_LEFT).str_pad($dates['day'],2,0,STR_PAD_LEFT).str_pad($dates['hour'],2,0,STR_PAD_LEFT).str_pad($dates['minute'],2,0,STR_PAD_LEFT);

            $totalsize[$timeid] = $totalsize[$timeid] ?? 0; // init if not present
            $totalsize[$timeid] += $tr['size'] ?? 0;        // otherwise increment
            $ticker = [];
            $ticker['timeid'] = $timeid;
            $ticker[7] = $tr['price'];
            $ticker[8] = $totalsize[$timeid] ?? 0;
            $this->markOHLC($ticker, 1, $this->instrument);
            $this->console->progressBar($i, $total);
            $i++;
        }

I'm new to coding so it's possible I'm missing something stupidly obvious here...

markOHLC was removed and it was for feeding the DB with data. For testing and playing with this comment out this line and you will see the data flowing in. This is not a long term solution.

Tried commenting out the markOHLC lines and got the result:

------------------------------------------------------------------
Set CBURL to api-public.sandbox.gdax.com before running this..
This will trade live otherwise, so be CAREFUL
PRESS ENTER TO CONTINUE
------------------------------------------------------------------

UPDATING RECENT Open, High, Low, Close data

Updating...

It keeps giving me "Updating..." but where is it doing so? I checked bowhead_OHLC and it shows empty set. Went ahead and uncommented markOHLC lines and added in:

    public function markOHLC($ticker)
    {
        $last_price = $ticker[7];
        $volume = $ticker[8];
        $timeid = date('YmdHi'); // 201705301522 unique for date
        $ins = \DB::insert("
            INSERT INTO bowhead_ohlc 
            (`instrument`, `timeid`, `open`, `high`, `low`, `close`, `volume`)
            VALUES
            ('ETH-USD', $timeid, $last_price, $last_price, $last_price, $last_price, $volume)
            ON DUPLICATE KEY UPDATE 
            `high`   = CASE WHEN `high` < VALUES(`high`) THEN VALUES(`high`) ELSE `high` END,
            `low`    = CASE WHEN `low` > VALUES(`low`) THEN VALUES(`low`) ELSE `low` END,
            `volume` = VALUES(`volume`),
            `close`  = VALUES(`close`)
        ");
        return true;
    }

and this populated bowhead_OHLC but the data (open, high, low, close, volume) was being repeated and not updated. Not sure how to tweak the code for markOHLC to get the proper data feed. So close!

I have started to fix the issues and upgrade this in my own fork. There is a README file so check there where did I stop. Please note this is under progress project and there might be a lot of errors. DO NOT USE REAL API just demo for testing until all is resolved.
Here is the forked version https://github.com/deakzsolt/bowhead