-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor all scrapers and release of web-ui
refactor all scrapers and initial release of web-ui
- Loading branch information
Showing
578 changed files
with
7,992 additions
and
358,086 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,7 +71,7 @@ Default email is `[email protected]` and password is `1234567890`. | |
`json` or `csv`. Default is `json`. | ||
|
||
``` | ||
http://127.0.0.1:8090/api/yahoo/symbol/THYAO.IS?startDate=2023-06-01&endDate=2023-09-30¤cy=TRY | ||
http://127.0.0.1:8090/api/v1/yahoo/symbols/THYAO.IS?startDate=2023-06-01&endDate=2023-09-30¤cy=TRY | ||
``` | ||
|
||
### Use with Pandas | ||
|
@@ -82,26 +82,89 @@ import pandas as pd | |
API_URL = 'http://127.0.0.1:8090' | ||
|
||
def get_data(symbol, start_date, end_date): | ||
url = f'{API_URL}/api/yahoo/symbol/{symbol}?startDate={start_date}&endDate={end_date}&format=csv' | ||
url = f'{API_URL}/api/v1/yahoo/symbols/{symbol}?startDate={start_date}&endDate={end_date}&format=csv' | ||
df = pd.read_csv(url, parse_dates=['Date']) | ||
df.set_index('Date', inplace=True) | ||
return df | ||
``` | ||
|
||
### Use as a Go package | ||
|
||
Both `tefas` and `yahoo` packages can be used independently from the web API, | ||
and they implement `Scraper` interface. | ||
|
||
```golang | ||
type Scraper interface { | ||
GetSymbolData(symbol string, startDate, endDate time.Time) (<-chan *SymbolPrice, error) | ||
} | ||
``` | ||
|
||
```golang | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"time" | ||
|
||
"github.com/ahmethakanbesel/finance-api/tefas" | ||
"github.com/ahmethakanbesel/finance-api/yahoo" | ||
) | ||
|
||
func main() { | ||
tefasScraper := tefas.NewScraper( | ||
tefas.WithWorkers(5), | ||
) | ||
|
||
// get last year's data for the given fund | ||
tefasData, err := tefasScraper.GetSymbolData("FUNDCODE", time.Now().AddDate(-1, 0, 0), time.Now()) | ||
if err != nil { | ||
// handle error | ||
} | ||
|
||
for data := range tefasData { | ||
fmt.Println(data.Date, data.Close) | ||
} | ||
|
||
yahooScraper := yahoo.NewScraper( | ||
yahoo.WithWorkers(5), | ||
) | ||
|
||
// get last year's data for the given symbol | ||
yahooData, err := yahooScraper.GetSymbolData("SYMBOLCODE", time.Now().AddDate(-1, 0, 0), time.Now()) | ||
if err != nil { | ||
// handle error | ||
} | ||
|
||
for data := range yahooData { | ||
fmt.Println(data.Date, data.Close) | ||
} | ||
} | ||
``` | ||
|
||
## Demo | ||
|
||
- `TEFAS (json)` | ||
|
||
``` | ||
https://finans.dokuz.gen.tr/api/tefas/fund/HKP?startDate=2023-06-01&endDate=2023-09-30¤cy=TRY | ||
https://finans.dokuz.gen.tr/api/v1/tefas/funds/HKP?startDate=2023-06-01&endDate=2023-09-30¤cy=TRY | ||
``` | ||
|
||
- `Yahoo Finance (csv)` | ||
|
||
``` | ||
https://finans.dokuz.gen.tr/api/yahoo/symbol/THYAO.IS?startDate=2023-06-01&endDate=2023-09-30¤cy=TRY&format=csv | ||
https://finans.dokuz.gen.tr/api/v1/yahoo/symbols/THYAO.IS?startDate=2023-06-01&endDate=2023-09-30¤cy=TRY&format=csv | ||
``` | ||
|
||
## Web UI | ||
|
||
The web UI is incomplete, and it is not ready to work out of the box. The source | ||
code can be found under `/ui` folder. | ||
|
||
### Preview | ||
|
||
![web ui preview](/docs/web-ui-preview.png "web ui preview") | ||
|
||
## Credits | ||
|
||
- [Pocketbase](https://github.com/pocketbase/pocketbase) | ||
- [Tremor](https://www.tremor.so/) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.