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
67
68
69
70
71
72
73
74
75
76
77
78
79
|
#ifndef PORTFOLIO_H
#define PORTFOLIO_H
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "api.h"
#define REMOVE 0
#define ADD 1
#define SET 2
const char* portfolio_file;
void portfolio_file_init();
/**
* Adds quantity_shares of given currency at
* given price to portfolio
* @param id name of currency
* @param quantity_shares quantity_shares of currency
* @param purchase_price quantity_shares of money spent
* @param fp portfolio file
*/
void portfolio_modify(char* ticker_name_string, double quantity_shares, double usd_spent, FILE* fp, int option);
/**
* Taken from the portfolio file, returns a double
* of the quantity_shares of crypto
* @param id the crypto
* @param fp portfolio file
* @return the quantity_shares
*/
double portfolio_get_quantity_shares(char* ticker_name_string, FILE* fp);
/**
* Taken from the portfolio file, returns a double
* of the quantity_shares of money spent of a crypto
* @param id the crypto
* @param fp portfolio file
* @return the quantity_shares spent
*/
double portfolio_get_usd_spent(char* ticker_name_string, FILE* fp);
/**
* Prints current holdings of all currencies
* @param api_data STRING to hold data in
* @param crypto_data JSON to hold STRING data in
* @param fp portfolio file
*/
void portfolio_print_all(FILE* fp);
/**
* Prints current holdings of a currency
* @param id name of currency
* @param fp portfolio file
*/
double* portfolio_print_stock(char* ticker_name_string, FILE* fp);
/**
* Sets stream pointer to first digit
* of currency quantity_shares if exists, otherwise
* sets stream pointer to beginning of stream
* @param id name of currency
* @param fp portfolio file
* @return 1 if contains, 0 if not
*/
int portfolio_contains(char* ticker_name_string, FILE* fp);
/**
* Given a file stream pointing to
* the first digit of a number,
* return the number as a double
* @param fp the file
* @return the value
*/
double get_next_val(FILE* fp);
#endif
|