func convert2struct(_okOrderBook _OKOrderBook) (okOrderBook OKOrderBook) { for k, v := range _okOrderBook.Asks { switch vt := v.(type) { case []interface{}: for ik, iv := range vt { switch ik { case 0: okOrderBook.Asks[k].Price = util.InterfaceToFloat64(iv) case 1: okOrderBook.Asks[k].Amount = util.InterfaceToFloat64(iv) } } } } for k, v := range _okOrderBook.Bids { switch vt := v.(type) { case []interface{}: for ik, iv := range vt { switch ik { case 0: okOrderBook.Bids[k].Price = util.InterfaceToFloat64(iv) case 1: okOrderBook.Bids[k].Amount = util.InterfaceToFloat64(iv) } } } } return }
func parse_buy_sell(sells_buys []interface{}, sells_buys_data *[10]SellBuy) bool { for k, v := range sells_buys { switch vt := v.(type) { case map[string]interface{}: logger.Debugln(k, " is a map:") logger.Debugf("sells/buys[%d]\n", k) for ik, iv := range vt { switch ik { case "price": sells_buys_data[k].Price = util.InterfaceToFloat64(iv) case "level": sells_buys_data[k].Level = util.InterfaceToFloat64(iv) case "amount": sells_buys_data[k].Amount = util.InterfaceToFloat64(iv) } } default: logger.Errorln(k, v) logger.Fatalln("don't know the type, crash!") return false } } return true }
// just f**k the huobi old shit bug func parse_topsell(topsells map[string]interface{}, topsells_data *[5]Top_buy_sell) bool { index := 4 for k, v := range topsells { switch vt := v.(type) { case map[string]interface{}: logger.Debugln(k, " is a map:") logger.Debugf("topsells[%s]\n", k) for ik, iv := range vt { logger.Debugln(ik, iv) switch ik { case "price": topsells_data[index].Price = util.InterfaceToFloat64(iv) case "amount": topsells_data[index].Amount = util.InterfaceToFloat64(iv) case "level": topsells_data[index].Level = util.InterfaceToFloat64(iv) case "accu": topsells_data[index].Accu = util.InterfaceToFloat64(iv) } } index-- default: logger.Errorln(k, v) logger.Fatalln("don't know the type, crash!") return false } } return true }
func parse_trade(trades []interface{}, trades_data *[60]Trade) bool { for k, v := range trades { switch vt := v.(type) { case map[string]interface{}: logger.Debugln(k, " is a map:") logger.Debugf("trades[%d]\n", k) for ik, iv := range vt { switch ik { case "time": trades_data[k].Time = iv.(string) case "price": trades_data[k].Price = util.InterfaceToFloat64(iv) case "amount": trades_data[k].Amount = util.InterfaceToFloat64(iv) case "type": trades_data[k].Type = iv.(string) } } default: logger.Errorln(k, v) logger.Fatalln("don't know the type, crash!") return false } } return true }