diff --git a/lib/bitflyer.ml b/lib/bitflyer.ml index d959b0f..4fa79e3 100644 --- a/lib/bitflyer.ml +++ b/lib/bitflyer.ml @@ -3,10 +3,15 @@ open Common let buy auth currency_pair ?(order=Market) amount = Lwt_main.run begin - BitflyerApi.sendchildorder auth currency_pair order Buy amount + BitflyerApi.me_sendchildorder auth currency_pair order Buy amount >>= fun json -> Log.debug "buy: %s" (Json.to_string json); Lwt.return () end +let get_executions auth currency_pair = + Lwt_main.run begin + BitflyerApi.me_getexecutions auth currency_pair + end + module Datetime = Datetime module Log = Log diff --git a/lib/bitflyerApi.ml b/lib/bitflyerApi.ml index 1afc8fe..ed5fd27 100644 --- a/lib/bitflyerApi.ml +++ b/lib/bitflyerApi.ml @@ -1,9 +1,25 @@ -let getticker = Ticker.getticker +let getmarkets = Public.getmarkets +let markets = Public.markets + +let getboard = Public.getboard +let board = Public.board + +let getticker = Public.getticker +let ticker = Public.ticker + +let getexecutions = Public.getexecutions +let executions = Public.executions + +let getboardstate = Public.getboardstate + +let gethealth = Public.gethealth + +let getchats = Public.getchats let getbalance = Assets.getbalance -let sendchildorder = Trade.sendchildorder +let me_sendchildorder = Trade.sendchildorder -let getchildorders = Trade.getchildorders +let me_getchildorders = Trade.getchildorders -let getexecutions = Trade.getexecutions +let me_getexecutions = Trade.getexecutions diff --git a/lib/bitflyerApi.mli b/lib/bitflyerApi.mli index 22fcd81..cc08def 100644 --- a/lib/bitflyerApi.mli +++ b/lib/bitflyerApi.mli @@ -1,14 +1,30 @@ open Common -val getticker : product_code -> Ticker.response Lwt.t +val getmarkets : Json.t Lwt.t +val markets : Json.t Lwt.t + +val getboard : product_code -> Json.t Lwt.t +val board : product_code -> Json.t Lwt.t + +val getexecutions : product_code -> Json.t Lwt.t +val executions : product_code -> Json.t Lwt.t + +val getboardstate : product_code -> Json.t Lwt.t + +val gethealth : product_code -> string Lwt.t + +val getchats : product_code -> Json.t Lwt.t + +val getticker : product_code -> Public.ticker Lwt.t +val ticker : product_code -> Public.ticker Lwt.t val getbalance : Auth.t -> Assets.balance list Lwt.t -val sendchildorder : +val me_sendchildorder : Auth.t -> product_code -> order_type -> side -> float -> Json.t Lwt.t -val getchildorders : +val me_getchildorders : Auth.t -> product_code -> Trade.order list Lwt.t -val getexecutions : +val me_getexecutions : Auth.t -> product_code -> Trade.execution list Lwt.t diff --git a/lib/ticker.ml b/lib/ticker.ml deleted file mode 100644 index 58eef7b..0000000 --- a/lib/ticker.ml +++ /dev/null @@ -1,39 +0,0 @@ -open Lwt -open Common - -type response = { - product_code: string; - (*TODO: "state": "RUNNING",*) - timestamp: string; - (*TODO: "tick_id": 3579,*) - best_bid: float; - best_ask: float; - (*TODO: "best_bid_size": 0.1,*) - (*TODO: "best_ask_size": 5,*) - (*TODO: "total_bid_depth": 15.13,*) - (*TODO: "total_ask_depth": 20,*) - (*TODO: "market_bid_size": 0,*) - (*TODO: "market_ask_size": 0,*) - (*TODO: "ltp": 31690,*) - (*TODO: "volume": 16819.26,*) - (*TODO: "volume_by_product": 6819.26*) -} - -let response_of_json json = - let open Json.Util in - let product_code = member "product_code" json |> to_string in - let timestamp = member "timestamp" json |> to_string in - let best_bid = member "best_bid" json |> to_float in - let best_ask = member "best_ask" json |> to_float in - { - product_code; - timestamp; - best_bid; - best_ask; - } - -let getticker product_code = - let path = "/v1/getticker" in - let query = [("product_code", product_code)] in - ApiCommon.get_public path query >>= fun json -> - Lwt.return (response_of_json json)