2019-08-12 16:25:03 +00:00
|
|
|
|
#pragma once
|
|
|
|
|
#include "Production.h"
|
2019-08-22 15:56:53 +00:00
|
|
|
|
#include "Market.h"
|
|
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
|
|
|
|
|
|
using std::pair;
|
|
|
|
|
using std::map;
|
|
|
|
|
|
|
|
|
|
class SellProduction
|
2019-08-12 16:25:03 +00:00
|
|
|
|
{
|
|
|
|
|
public:
|
2019-08-22 15:56:53 +00:00
|
|
|
|
using Amount = float;
|
|
|
|
|
using Price = float;
|
|
|
|
|
using PriceList = pair<Price, Amount>;
|
|
|
|
|
using PriceMap = pair<Price, PriceList>;
|
|
|
|
|
|
|
|
|
|
SellProduction(shared_ptr<Production> pt_pdt) : p_pdt(pt_pdt) {}
|
|
|
|
|
|
|
|
|
|
// ί<><CEAF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӿ<EFBFBD>
|
|
|
|
|
void new_request(shared_ptr<Request> pn_req);
|
|
|
|
|
bool cancel_request(shared_ptr<Request> pn_req);
|
2019-08-12 16:25:03 +00:00
|
|
|
|
|
2019-08-22 15:56:53 +00:00
|
|
|
|
const float get_average_price();
|
|
|
|
|
const float get_selling_amount();
|
|
|
|
|
const float get_buying_amount();
|
|
|
|
|
|
|
|
|
|
|
2019-08-12 16:25:03 +00:00
|
|
|
|
private:
|
2019-08-22 15:56:53 +00:00
|
|
|
|
// <20><>λ<EFBFBD><CEBB>
|
|
|
|
|
map<Price, PriceList> pce_s_lst, pce_b_lst;
|
|
|
|
|
// <20><>Ʒָ<C6B7><D6B8>
|
|
|
|
|
shared_ptr<Production> p_pdt;
|
|
|
|
|
// <20><><EFBFBD>۽<EFBFBD><DBBD><EFBFBD>ί<EFBFBD><CEAF>
|
|
|
|
|
vector<shared_ptr<Request>> reqs_sl;
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ί<EFBFBD><CEAF>
|
|
|
|
|
vector<shared_ptr<Request>> reqs_by;
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>ͳ<EFBFBD><CDB3>
|
|
|
|
|
float buy_amt = 0.0, sell_amt = 0.0;
|
|
|
|
|
// ƽ<><C6BD><EFBFBD>۸<EFBFBD>
|
|
|
|
|
float price_avg = 0.0;
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD>¼<EFBFBD>λ<EFBFBD><CEBB><EFBFBD>ӿ<EFBFBD>
|
|
|
|
|
void update_buying_map(Price price, Amount amount);
|
|
|
|
|
void update_selling_map(Price price, Amount amount);
|
|
|
|
|
void update_map(map<Price, PriceList>& pce_map, Price price, Amount amount);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-08-12 16:25:03 +00:00
|
|
|
|
};
|
|
|
|
|
|