I think I'd stream to file, and have J busy wait (perhaps a second of sleep
while waiting, to keep load down) when it's caught up.

Would you want an event for every record which comes in, or would it make
more sense to skip forward to the most recent complete event when more data
becomes available? Or would you want to experiment with this?

Also, is that enough of an explanation? I could draft something up, I
guess. (But not exactly right now.)

Thanks,

-- 
Raul


On Tue, Jul 15, 2014 at 12:14 AM, Francisco Gonzalez Velasco <
[email protected]> wrote:

> Hello, my experience programming in J is very limited, so Inee your help...
>
> I´m using J64-602 to connect to a financial data source using their REST
> API, so I can get static data:
>
> To get the information about EUR USD in the last 5 days
> (instrument=EUR_USD&granularity=D&count=5) I use this command:
>
>    load 'web/gethttp'
> >    load 'convert/json'
>
>    >>(<1 2){dec_json('-s -k -H "Authorization: Bearer
> > XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY"')
> gethttp'
> >
> https://api-fxpractice.oanda.com/v1/candles?instrument=EUR_USD&granularity=D&count=5&candleFormat=bidask
> > '
> >
> >
> ┌───────────────────────────┬───────┬───────┬───────┬───────┬───────┬───────┬────────┬────────┬──────┬──────────┐
> > │time                       │openBid│openAsk│highBid│highAsk│lowBid
> > │lowAsk │closeBid│closeAsk│volume│complete  │
> >
> >
> ├───────────────────────────┼───────┼───────┼───────┼───────┼───────┼───────┼────────┼────────┼──────┼──────────┤
> >
> │2014-06-10T21:00:00.000000Z│1.35431│1.35472│1.35565│1.35576│1.35212│1.35224│1.353
> >   │1.3532  │42528 │json_true │
> >
> >
> └───────────────────────────┴───────┴───────┴───────┴───────┴───────┴───────┴────────┴────────┴──────┴──────────┘
> >
> >
> ┌───────────────────────────┬───────┬───────┬───────┬───────┬───────┬───────┬────────┬────────┬──────┬──────────┐
> > │time                       │openBid│openAsk│highBid│highAsk│lowBid
> > │lowAsk │closeBid│closeAsk│volume│complete  │
> >
> >
> ├───────────────────────────┼───────┼───────┼───────┼───────┼───────┼───────┼────────┼────────┼──────┼──────────┤
> > │2014-06-11T21:00:00.000000Z│1.353  │1.35319│1.35715│1.3573
> > │1.35117│1.35129│1.35494 │1.35536 │54799 │json_true │
> >
> >
> └───────────────────────────┴───────┴───────┴───────┴───────┴───────┴───────┴────────┴────────┴──────┴──────────┘
> >
> >
> ┌───────────────────────────┬───────┬───────┬───────┬───────┬───────┬───────┬────────┬────────┬──────┬──────────┐
> > │time                       │openBid│openAsk│highBid│highAsk│lowBid
> > │lowAsk │closeBid│closeAsk│volume│complete  │
> >
> >
> ├───────────────────────────┼───────┼───────┼───────┼───────┼───────┼───────┼────────┼────────┼──────┼──────────┤
> >
> │2014-06-12T21:00:00.000000Z│1.35511│1.35566│1.35786│1.35799│1.35204│1.35215│1.35374
> > │1.35468 │46632 │json_true │
> >
> >
> └───────────────────────────┴───────┴───────┴───────┴───────┴───────┴───────┴────────┴────────┴──────┴──────────┘
> >
> >
> ┌───────────────────────────┬───────┬───────┬───────┬───────┬───────┬───────┬────────┬────────┬──────┬──────────┐
> > │time                       │openBid│openAsk│highBid│highAsk│lowBid
> > │lowAsk │closeBid│closeAsk│volume│complete  │
> >
> >
> ├───────────────────────────┼───────┼───────┼───────┼───────┼───────┼───────┼────────┼────────┼──────┼──────────┤
> >
> │2014-06-15T21:00:00.000000Z│1.35391│1.35458│1.35791│1.35804│1.35124│1.35137│1.35733
> > │1.35747 │39482 │json_true │
> >
> >
> └───────────────────────────┴───────┴───────┴───────┴───────┴───────┴───────┴────────┴────────┴──────┴──────────┘
> >
> >
> ┌───────────────────────────┬───────┬───────┬───────┬───────┬───────┬───────┬────────┬────────┬──────┬──────────┐
> > │time                       │openBid│openAsk│highBid│highAsk│lowBid
> > │lowAsk │closeBid│closeAsk│volume│complete  │
> >
> >
> ├───────────────────────────┼───────┼───────┼───────┼───────┼───────┼───────┼────────┼────────┼──────┼──────────┤
> > │2014-06-16T21:00:00.000000Z│1.35716│1.3573
> > │1.35866│1.35878│1.35526│1.35538│1.35566 │1.35577 │10173 │json_false│
> >
> >
> └───────────────────────────┴───────┴───────┴───────┴───────┴───────┴───────┴────────┴────────┴──────┴──────────┘
> >
>
>
> Now I need to know how to use streaming data... Data will be delivered in
> real time.
>
> I would use last information arrived and store data to form a database.
>
> The command to get the streaming data is:
>
> ('-s -k -H "Authorization: Bearer
> XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY"')
> gethttp'https://stream-fxpractice.oanda.com
> /v1/prices?accountId=abcdefg&instruments=EUR_USD'
>
>
> When I use curl in the console to get streaming data the command is:
>
> C:\Users\Francisco>curl -k -H "Authorization: Bearer
> XXXXXXXXXXXXXXXXXXXXXXX
> > XXXXXXXX-YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY" "
> > https://stream-fxpractice.oanda.com/v1/prices?accountId=
> > <
> https://stream-fxpractice.oanda.com/v1/prices?accountId=1125870&instruments=EUR_USD
> >
> > abcdefg&instruments=EUR_USD
> > <
> https://www.google.com/url?q=https%3A%2F%2Fstream-fxpractice.oanda.com%2Fv1%2Fprices%3FaccountId%3D1125870%26instruments%3DEUR_USD&sa=D&sntz=1&usg=AFQjCNEQy2PxdhBR4bYOLWuHEZSp37Xa-A
> >
> > "
>
>
> And the incoming data is:
>
>
> {"instrument":"EUR_USD","time":"2014-06-17T08:50:11.313886Z","bid":1.35744,"ask":1.35757}
> >
> >
> {"instrument":"EUR_USD","time":"2014-06-17T08:50:11.413276Z","bid":1.35745,"ask":1.35757}
> >
> >
> {"instrument":"EUR_USD","time":"2014-06-17T08:50:11.423912Z","bid":1.35743,"ask":1.35755}
> >
> >
> {"instrument":"EUR_USD","time":"2014-06-17T08:50:11.518162Z","bid":1.35744,"ask":1.35755}
> >
> >
> {"instrument":"EUR_USD","time":"2014-06-17T08:50:11.618055Z","bid":1.35743,"ask":1.35756}
> >
> >
> {"instrument":"EUR_USD","time":"2014-06-17T08:50:11.691201Z","bid":1.35744,"ask":1.35756}
> >
> >
> {"instrument":"EUR_USD","time":"2014-06-17T08:50:11.824403Z","bid":1.35745,"ask":1.35756}
> >
> >
> {"instrument":"EUR_USD","time":"2014-06-17T08:50:12.250563Z","bid":1.35745,"ask":1.35758}
> > {"heartbeat":{"time":"2014-06-17T08:50:12.547586Z"}}
> >
> >
> {"instrument":"EUR_USD","time":"2014-06-17T08:50:12.611163Z","bid":1.35746,"ask":1.35758}
> >
> >
> {"instrument":"EUR_USD","time":"2014-06-17T08:50:13.168306Z","bid":1.35746,"ask":1.35757}
> >
> >
> {"instrument":"EUR_USD","time":"2014-06-17T08:50:13.527477Z","bid":1.35745,"ask":1.35757}
> >
> >
> {"instrument":"EUR_USD","time":"2014-06-17T08:50:14.009987Z","bid":1.35746,"ask":1.35756}
> >
> >
> {"instrument":"EUR_USD","time":"2014-06-17T08:50:14.109158Z","bid":1.35745,"ask":1.35757}
> >
> >
> {"instrument":"EUR_USD","time":"2014-06-17T08:50:14.228386Z","bid":1.35743,"ask":1.35755}
> >
> >
> {"instrument":"EUR_USD","time":"2014-06-17T08:50:14.314567Z","bid":1.35744,"ask":1.35755}
> >
> >
> {"instrument":"EUR_USD","time":"2014-06-17T08:50:14.912960Z","bid":1.35742,"ask":1.35753}
> > {"heartbeat":{"time":"2014-06-17T08:50:15.036929Z"}}
> >
> >
> {"instrument":"EUR_USD","time":"2014-06-17T08:50:15.214964Z","bid":1.3574,"ask":1.35751}
>
>
> Token and account number have been changed
>
>
> 1) I'd like to know how to have a variable holding the most recent data
> sent by the data provider. And an event triggering when a new value arrives
> so actions can be taken depending on the values.
> 2) I'd like to write the incoming data to disk (as a csv file, JDB,...)
>  for persistance.
>
> Cheers
>
> Francisco
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to