Subscribed unsubscribe Subscribe Subscribe

F# Monkey

about

OANDA API からデーター取得のメモ

最新のローソク足を取得

1時間足のローソク足を2本取得する

#load "/./Users/kohei/Documents/01_F#/OANDAfs/oandafs.fsx"
open oandafs.Oandafs

let env   = Environment.Live
let id    = "**********"
let token = "**********"
let info  = API().Init( env, id, token )

let param = [   currency.GPB_JPY         /// 対象となる通貨
                granularity.H1           /// 時間足
                ("count","2")            /// 取得したいローソク足の本数
                 
                /// ここはおまじない
                alignmentTimezone.Japan  /// タイムゾーンはJST
                dailyAlignment.H7        /// ヘッドを調整
            ]

Rates(info).Get_History param |> printfn "%s"

結果

{
    "instrument" : "GBP_JPY",
    "granularity" : "H1",
    "candles" : [
        {
            "time" : "2017-04-07T19:00:00.000000Z",
            "openBid" : 137.583,
            "openAsk" : 137.612,
            "highBid" : 137.723,
            "highAsk" : 137.753,
            "lowBid" : 137.512,
            "lowAsk" : 137.539,
            "closeBid" : 137.571,
            "closeAsk" : 137.598,
            "volume" : 8103,
            "complete" : true
        },
        {
            "time" : "2017-04-07T20:00:00.000000Z",
            "openBid" : 137.57,
            "openAsk" : 137.598,
            "highBid" : 137.622,
            "highAsk" : 137.655,
            "lowBid" : 137.327,
            "lowAsk" : 137.378,
            "closeBid" : 137.372,
            "closeAsk" : 137.448,
            "volume" : 6087,
            "complete" : true
        }
    ]
}

期間を指定してローソク足を取得

期間:2017/4/3 9時から12時までローソク足3本取得する

#load "/./Users/kohei/Documents/01_F#/OANDAfs/oandafs.fsx"
open oandafs.Oandafs

let env   = Environment.Live
let id    = "********"
let token = "********"
let info  = API().Init( env, id, token )

let startDate = System.DateTime( 2017,4,3,9,0,0)  |> toEET /// 日本の時刻をヨーロッパの時刻に変換する
let endDate   = System.DateTime( 2017,4,3,13,0,0) |> toEET /// 日本の時刻をヨーロッパの時刻に変換する

let param = [  currency.GPB_JPY     /// 対象となる通貨
               granularity.H1       /// 時間足
               ("start",startDate)  /// 開始時刻
               ("end"  , endDate )  /// 終了時刻
               includeFirst.False   /// ヘッドは含めない
               
               /// おまじない
               alignmentTimezone.Japan
               dailyAlignment.H7   
            ]

Rates(info).Get_History param |> printfn "%s"

結果

{
    "instrument" : "GBP_JPY",
    "granularity" : "H1",
    "candles" : [
        {
            "time" : "2017-04-03T03:00:00.000000Z",
            "openBid" : 139.66,
            "openAsk" : 139.689,
            "highBid" : 139.717,
            "highAsk" : 139.754,
            "lowBid" : 139.516,
            "lowAsk" : 139.546,
            "closeBid" : 139.553,
            "closeAsk" : 139.583,
            "volume" : 4431,
            "complete" : true
        },
        {
            "time" : "2017-04-03T04:00:00.000000Z",
            "openBid" : 139.547,
            "openAsk" : 139.577,
            "highBid" : 139.686,
            "highAsk" : 139.717,
            "lowBid" : 139.544,
            "lowAsk" : 139.575,
            "closeBid" : 139.625,
            "closeAsk" : 139.656,
            "volume" : 4323,
            "complete" : true
        },
        {
            "time" : "2017-04-03T05:00:00.000000Z",
            "openBid" : 139.625,
            "openAsk" : 139.655,
            "highBid" : 139.89,
            "highAsk" : 139.922,
            "lowBid" : 139.623,
            "lowAsk" : 139.654,
            "closeBid" : 139.724,
            "closeAsk" : 139.758,
            "volume" : 5534,
            "complete" : true
        }
    ]
}
Remove all ads