-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathme_market.h
67 lines (52 loc) · 1.91 KB
/
me_market.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
* Description:
* History: yang@haipo.me, 2017/03/16, create
*/
# ifndef _ME_MARKET_H_
# define _ME_MARKET_H_
# include "me_config.h"
extern uint64_t order_id_start;
extern uint64_t deals_id_start;
typedef struct order_t {
uint64_t id;
uint32_t type;
uint32_t side;
double create_time;
double update_time;
uint32_t user_id;
char *market;
char *source;
mpd_t *price;
mpd_t *amount;
mpd_t *taker_fee;
mpd_t *maker_fee;
mpd_t *left;
mpd_t *freeze;
mpd_t *deal_stock;
mpd_t *deal_money;
mpd_t *deal_fee;
} order_t;
typedef struct market_t {
char *name;
char *stock;
char *money;
int stock_prec;
int money_prec;
int fee_prec;
mpd_t *min_amount;
dict_t *orders;
dict_t *users;
skiplist_t *asks;
skiplist_t *bids;
} market_t;
market_t *market_create(struct market *conf);
int market_get_status(market_t *m, size_t *ask_count, mpd_t *ask_amount, size_t *bid_count, mpd_t *bid_amount);
int market_put_limit_order(bool real, json_t **result, market_t *m, uint32_t user_id, uint32_t side, mpd_t *amount, mpd_t *price, mpd_t *taker_fee, mpd_t *maker_fee, const char *source);
int market_put_market_order(bool real, json_t **result, market_t *m, uint32_t user_id, uint32_t side, mpd_t *amount, mpd_t *taker_fee, const char *source);
int market_cancel_order(bool real, json_t **result, market_t *m, order_t *order);
int market_put_order(market_t *m, order_t *order);
json_t *get_order_info(order_t *order);
order_t *market_get_order(market_t *m, uint64_t id);
skiplist_t *market_get_order_list(market_t *m, uint32_t user_id);
sds market_status(sds reply);
# endif