func (h OpenOrders) convert() (o xgen.OpenOrders) { // Convert campbx.OpenOrders to xgen.OpenOrders var err os.Error o.Sell = make(map[string]xgen.OpenOrder) o.Buy = make(map[string]xgen.OpenOrder) for _, order := range h.Buy { if order.Oid != "" { var t xgen.OpenOrder t.Date = time.Seconds() // Should use time.Parse to convert order.DateEntered to Unix time t.Price, err = strconv.Atof64(order.Price) check(err) t.Amount, err = strconv.Atof64(order.Quantity) check(err) o.Buy[order.Oid] = t } } for _, order := range h.Sell { if order.Oid != "" { var t xgen.OpenOrder t.Date = time.Seconds() // Should use time.Parse to convert order.DateEntered to Unix time t.Price, err = strconv.Atof64(order.Price) check(err) t.Amount, err = strconv.Atof64(order.Quantity) check(err) o.Sell[order.Oid] = t } } return }
func (h OpenOrders) convert() (o xgen.OpenOrders) { // Convert tradehill.OpenOrders to xgen.OpenOrders var err os.Error o.Sell = make(map[string]xgen.OpenOrder) o.Buy = make(map[string]xgen.OpenOrder) for _, order := range h.Orders { var t xgen.OpenOrder t.Date = order.Date t.Price, err = strconv.Atof64(order.Price) check(err) t.Amount, err = strconv.Atof64(order.Amount) check(err) if order.OrderType == 1 { // Sell order o.Sell[strconv.Itoa64(order.Oid)] = t } else if order.OrderType == 2 { // Buy order o.Buy[strconv.Itoa64(order.Oid)] = t } else { panic("Invalid order type") } } return }